1
The following changes since commit a2b5f8b8ab7b2c947823088103a40f0ff11fe06b:
1
The following changes since commit 08c9f7eec7002dac2da52c8265eb319aba381c86:
2
2
3
Merge tag 'pull-tcg-20230301' of https://gitlab.com/rth7680/qemu into staging (2023-03-01 19:19:20 +0000)
3
Merge tag 'darwin-20220712' of https://github.com/philmd/qemu into staging (2022-07-14 09:30:55 +0100)
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-20230302
7
https://github.com/legoater/qemu/ tags/pull-aspeed-20220714
8
8
9
for you to fetch changes up to b22a2d409b1acfdf0d63d1bb3595194ceb3d94da:
9
for you to fetch changes up to f0418558302ef9e140681e04250fc1ca265f3140:
10
10
11
aspeed/smc: Replace SysBus IRQs with GPIO lines (2023-03-02 13:57:50 +0100)
11
aspeed: Add fby35-bmc slot GPIO's (2022-07-14 16:24:38 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
aspeed queue:
14
aspeed queue:
15
15
16
* fix for the Aspeed I2C slave mode
16
* New ISL69259 device model
17
* a new I2C echo device from Klaus and its associated test in avocado.
17
* New fby35 multi-SoC machine (AST1030 BIC + AST2600 BMC)
18
* initial SoC cleanups to allow the use of block devices instead of
18
* Aspeed GPIO fixes
19
drives on the command line.
19
* Extension of m25p80 with write protect bits
20
* new facebook machines and eeprom fixes for the Fuji
20
* More avocado tests using the Aspeed SDK
21
* readline fix
22
21
23
----------------------------------------------------------------
22
----------------------------------------------------------------
24
Cédric Le Goater (4):
23
Cédric Le Goater (3):
25
tests/avocado/machine_aspeed.py: Add an I2C slave test
24
aspeed: fby35: Add a bootrom for the BMC
26
aspeed: Introduce a spi_boot region under the SoC
25
docs: aspeed: Minor updates
27
aspeed: Add a boot_rom overlap region in the SoC spi_boot container
26
test/avocado/machine_aspeed.py: Add SDK tests
28
aspeed/smc: Replace SysBus IRQs with GPIO lines
29
27
30
Dongli Zhang (1):
28
Iris Chen (2):
31
readline: fix hmp completion issue
29
hw: m25p80: Add Block Protect and Top Bottom bits for write protect
30
hw: m25p80: add tests for BP and TB bit write protect
32
31
33
Karthikeyan Pasupathi (2):
32
Joel Stanley (1):
34
hw/arm/aspeed: Adding new machine Yosemitev2 in QEMU
33
aspeed: sbc: Allow per-machine settings
35
hw/arm/aspeed: Adding new machine Tiogapass in QEMU
36
34
37
Klaus Jensen (2):
35
Peter Delevoryas (13):
38
hw/i2c: only schedule pending master when bus is idle
36
hw/i2c/pmbus: Add idle state to return 0xff's
39
hw/misc: add a toy i2c echo device
37
hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators
38
hw/sensor: Add Renesas ISL69259 device model
39
aspeed: Create SRAM name from first CPU index
40
aspeed: Refactor UART init for multi-SoC machines
41
aspeed: Make aspeed_board_init_flashes public
42
aspeed: Add fby35 skeleton
43
aspeed: Add AST2600 (BMC) to fby35
44
aspeed: Add AST1030 (BIC) to fby35
45
docs: aspeed: Add fby35 multi-SoC machine section
46
qtest/aspeed_gpio: Add input pin modification test
47
hw/gpio/aspeed: Don't let guests modify input pins
48
aspeed: Add fby35-bmc slot GPIO's
40
49
41
Sittisak Sinprem (2):
50
docs/system/arm/aspeed.rst | 62 ++++++++++++-
42
hw/at24c : modify at24c to support 1 byte address mode
51
include/hw/arm/aspeed_soc.h | 9 +-
43
aspeed/fuji : correct the eeprom size
52
include/hw/i2c/pmbus_device.h | 7 ++
53
include/hw/misc/aspeed_sbc.h | 13 +++
54
include/hw/sensor/isl_pmbus_vr.h | 5 ++
55
hw/arm/aspeed.c | 38 ++++++--
56
hw/arm/aspeed_ast10x0.c | 13 ++-
57
hw/arm/aspeed_ast2600.c | 13 ++-
58
hw/arm/aspeed_soc.c | 55 ++++++++----
59
hw/arm/fby35.c | 188 +++++++++++++++++++++++++++++++++++++++
60
hw/block/m25p80.c | 102 ++++++++++++++++++---
61
hw/gpio/aspeed_gpio.c | 15 ++--
62
hw/i2c/pmbus_device.c | 9 ++
63
hw/misc/aspeed_sbc.c | 42 ++++++++-
64
hw/sensor/isl_pmbus_vr.c | 40 +++++++++
65
tests/qtest/aspeed_gpio-test.c | 27 ++++++
66
tests/qtest/aspeed_smc-test.c | 111 +++++++++++++++++++++++
67
MAINTAINERS | 1 +
68
hw/arm/meson.build | 3 +-
69
tests/avocado/machine_aspeed.py | 68 ++++++++++++++
70
20 files changed, 764 insertions(+), 57 deletions(-)
71
create mode 100644 hw/arm/fby35.c
44
72
45
docs/system/arm/aspeed.rst | 2 +
46
hw/arm/aspeed_eeprom.h | 6 ++
47
include/hw/arm/aspeed_soc.h | 5 ++
48
include/hw/i2c/i2c.h | 2 +
49
hw/arm/aspeed.c | 159 ++++++++++++++++++++++++++++------------
50
hw/arm/aspeed_ast2600.c | 13 ++++
51
hw/arm/aspeed_eeprom.c | 45 ++++++++++++
52
hw/arm/aspeed_soc.c | 14 ++++
53
hw/arm/fby35.c | 8 +-
54
hw/i2c/aspeed_i2c.c | 2 +
55
hw/i2c/core.c | 37 ++++++----
56
hw/misc/i2c-echo.c | 156 +++++++++++++++++++++++++++++++++++++++
57
hw/nvram/eeprom_at24c.c | 30 +++++++-
58
hw/ssi/aspeed_smc.c | 5 +-
59
monitor/hmp.c | 8 +-
60
hw/misc/meson.build | 2 +
61
tests/avocado/machine_aspeed.py | 10 +++
62
17 files changed, 421 insertions(+), 83 deletions(-)
63
create mode 100644 hw/misc/i2c-echo.c
64
diff view generated by jsdifflib
New patch
1
From: Joel Stanley <joel@jms.id.au>
1
2
3
In order to correctly report secure boot running firmware the values
4
of certain registers must be set.
5
6
We don't yet have documentation from ASPEED on what they mean. The
7
meaning is inferred from u-boot's use of them.
8
9
Introduce properties so the settings can be configured per-machine.
10
11
Reviewed-by: Peter Delevoryas <pdel@fb.com>
12
Tested-by: Peter Delevoryas <pdel@fb.com>
13
Signed-off-by: Joel Stanley <joel@jms.id.au>
14
Message-Id: <20220628154740.1117349-4-clg@kaod.org>
15
Signed-off-by: Cédric Le Goater <clg@kaod.org>
16
---
17
include/hw/misc/aspeed_sbc.h | 13 +++++++++++
18
hw/misc/aspeed_sbc.c | 42 ++++++++++++++++++++++++++++++++++--
19
2 files changed, 53 insertions(+), 2 deletions(-)
20
21
diff --git a/include/hw/misc/aspeed_sbc.h b/include/hw/misc/aspeed_sbc.h
22
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/misc/aspeed_sbc.h
24
+++ b/include/hw/misc/aspeed_sbc.h
25
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(AspeedSBCState, AspeedSBCClass, ASPEED_SBC)
26
27
#define ASPEED_SBC_NR_REGS (0x93c >> 2)
28
29
+#define QSR_AES BIT(27)
30
+#define QSR_RSA1024 (0x0 << 12)
31
+#define QSR_RSA2048 (0x1 << 12)
32
+#define QSR_RSA3072 (0x2 << 12)
33
+#define QSR_RSA4096 (0x3 << 12)
34
+#define QSR_SHA224 (0x0 << 10)
35
+#define QSR_SHA256 (0x1 << 10)
36
+#define QSR_SHA384 (0x2 << 10)
37
+#define QSR_SHA512 (0x3 << 10)
38
+
39
struct AspeedSBCState {
40
SysBusDevice parent;
41
42
+ bool emmc_abr;
43
+ uint32_t signing_settings;
44
+
45
MemoryRegion iomem;
46
47
uint32_t regs[ASPEED_SBC_NR_REGS];
48
diff --git a/hw/misc/aspeed_sbc.c b/hw/misc/aspeed_sbc.c
49
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/misc/aspeed_sbc.c
51
+++ b/hw/misc/aspeed_sbc.c
52
@@ -XXX,XX +XXX,XX @@
53
#include "qemu/osdep.h"
54
#include "qemu/log.h"
55
#include "qemu/error-report.h"
56
+#include "hw/qdev-properties.h"
57
#include "hw/misc/aspeed_sbc.h"
58
#include "qapi/error.h"
59
#include "migration/vmstate.h"
60
@@ -XXX,XX +XXX,XX @@
61
#define R_STATUS (0x014 / 4)
62
#define R_QSR (0x040 / 4)
63
64
+/* R_STATUS */
65
+#define ABR_EN BIT(14) /* Mirrors SCU510[11] */
66
+#define ABR_IMAGE_SOURCE BIT(13)
67
+#define SPI_ABR_IMAGE_SOURCE BIT(12)
68
+#define SB_CRYPTO_KEY_EXP_DONE BIT(11)
69
+#define SB_CRYPTO_BUSY BIT(10)
70
+#define OTP_WP_EN BIT(9)
71
+#define OTP_ADDR_WP_EN BIT(8)
72
+#define LOW_SEC_KEY_EN BIT(7)
73
+#define SECURE_BOOT_EN BIT(6)
74
+#define UART_BOOT_EN BIT(5)
75
+/* bit 4 reserved*/
76
+#define OTP_CHARGE_PUMP_READY BIT(3)
77
+#define OTP_IDLE BIT(2)
78
+#define OTP_MEM_IDLE BIT(1)
79
+#define OTP_COMPARE_STATUS BIT(0)
80
+
81
+/* QSR */
82
+#define QSR_RSA_MASK (0x3 << 12)
83
+#define QSR_HASH_MASK (0x3 << 10)
84
+
85
static uint64_t aspeed_sbc_read(void *opaque, hwaddr addr, unsigned int size)
86
{
87
AspeedSBCState *s = ASPEED_SBC(opaque);
88
@@ -XXX,XX +XXX,XX @@ static void aspeed_sbc_reset(DeviceState *dev)
89
memset(s->regs, 0, sizeof(s->regs));
90
91
/* Set secure boot enabled with RSA4096_SHA256 and enable eMMC ABR */
92
- s->regs[R_STATUS] = 0x000044C6;
93
- s->regs[R_QSR] = 0x07C07C89;
94
+ s->regs[R_STATUS] = OTP_IDLE | OTP_MEM_IDLE;
95
+
96
+ if (s->emmc_abr) {
97
+ s->regs[R_STATUS] &= ABR_EN;
98
+ }
99
+
100
+ if (s->signing_settings) {
101
+ s->regs[R_STATUS] &= SECURE_BOOT_EN;
102
+ }
103
+
104
+ s->regs[R_QSR] = s->signing_settings;
105
}
106
107
static void aspeed_sbc_realize(DeviceState *dev, Error **errp)
108
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_aspeed_sbc = {
109
}
110
};
111
112
+static Property aspeed_sbc_properties[] = {
113
+ DEFINE_PROP_BOOL("emmc-abr", AspeedSBCState, emmc_abr, 0),
114
+ DEFINE_PROP_UINT32("signing-settings", AspeedSBCState, signing_settings, 0),
115
+ DEFINE_PROP_END_OF_LIST(),
116
+};
117
+
118
static void aspeed_sbc_class_init(ObjectClass *klass, void *data)
119
{
120
DeviceClass *dc = DEVICE_CLASS(klass);
121
@@ -XXX,XX +XXX,XX @@ static void aspeed_sbc_class_init(ObjectClass *klass, void *data)
122
dc->realize = aspeed_sbc_realize;
123
dc->reset = aspeed_sbc_reset;
124
dc->vmsd = &vmstate_aspeed_sbc;
125
+ device_class_set_props(dc, aspeed_sbc_properties);
126
}
127
128
static const TypeInfo aspeed_sbc_info = {
129
--
130
2.35.3
131
132
diff view generated by jsdifflib
1
It's cleaner and removes the curious '+ 1' required to skip the DMA
1
From: Peter Delevoryas <pdel@fb.com>
2
IRQ line of the controller.
3
2
4
Signed-off-by: Cédric Le Goater <clg@kaod.org>
3
Signed-off-by: Peter Delevoryas <pdel@fb.com>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Titus Rwantare <titusr@google.com>
5
Message-Id: <20220701000626.77395-2-me@pjd.dev>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
---
7
---
8
hw/arm/aspeed.c | 2 +-
8
include/hw/i2c/pmbus_device.h | 7 +++++++
9
hw/ssi/aspeed_smc.c | 5 +----
9
hw/i2c/pmbus_device.c | 9 +++++++++
10
2 files changed, 2 insertions(+), 5 deletions(-)
10
2 files changed, 16 insertions(+)
11
11
12
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
12
diff --git a/include/hw/i2c/pmbus_device.h b/include/hw/i2c/pmbus_device.h
13
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/arm/aspeed.c
14
--- a/include/hw/i2c/pmbus_device.h
15
+++ b/hw/arm/aspeed.c
15
+++ b/include/hw/i2c/pmbus_device.h
16
@@ -XXX,XX +XXX,XX @@ void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
16
@@ -XXX,XX +XXX,XX @@ enum pmbus_registers {
17
qdev_realize_and_unref(dev, BUS(s->spi), &error_fatal);
17
PMBUS_MFR_MAX_TEMP_1 = 0xC0, /* R/W word */
18
18
PMBUS_MFR_MAX_TEMP_2 = 0xC1, /* R/W word */
19
cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0);
19
PMBUS_MFR_MAX_TEMP_3 = 0xC2, /* R/W word */
20
- sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line);
20
+ PMBUS_IDLE_STATE = 0xFF,
21
+ qdev_connect_gpio_out_named(DEVICE(s), "cs", i, cs_line);
21
};
22
23
/* STATUS_WORD */
24
@@ -XXX,XX +XXX,XX @@ int pmbus_page_config(PMBusDevice *pmdev, uint8_t page_index, uint64_t flags);
25
*/
26
void pmbus_check_limits(PMBusDevice *pmdev);
27
28
+/**
29
+ * Enter an idle state where only the PMBUS_ERR_BYTE will be returned
30
+ * indefinitely until a new command is issued.
31
+ */
32
+void pmbus_idle(PMBusDevice *pmdev);
33
+
34
extern const VMStateDescription vmstate_pmbus_device;
35
36
#define VMSTATE_PMBUS_DEVICE(_field, _state) { \
37
diff --git a/hw/i2c/pmbus_device.c b/hw/i2c/pmbus_device.c
38
index XXXXXXX..XXXXXXX 100644
39
--- a/hw/i2c/pmbus_device.c
40
+++ b/hw/i2c/pmbus_device.c
41
@@ -XXX,XX +XXX,XX @@ void pmbus_check_limits(PMBusDevice *pmdev)
22
}
42
}
23
}
43
}
24
44
25
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
45
+void pmbus_idle(PMBusDevice *pmdev)
26
index XXXXXXX..XXXXXXX 100644
46
+{
27
--- a/hw/ssi/aspeed_smc.c
47
+ pmdev->code = PMBUS_IDLE_STATE;
28
+++ b/hw/ssi/aspeed_smc.c
48
+}
29
@@ -XXX,XX +XXX,XX @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp)
49
+
30
50
/* assert the status_cml error upon receipt of malformed command */
31
/* Setup cs_lines for peripherals */
51
static void pmbus_cml_error(PMBusDevice *pmdev)
32
s->cs_lines = g_new0(qemu_irq, asc->cs_num_max);
52
{
33
-
53
@@ -XXX,XX +XXX,XX @@ static uint8_t pmbus_receive_byte(SMBusDevice *smd)
34
- for (i = 0; i < asc->cs_num_max; ++i) {
54
}
35
- sysbus_init_irq(sbd, &s->cs_lines[i]);
55
break;
36
- }
56
37
+ qdev_init_gpio_out_named(DEVICE(s), s->cs_lines, "cs", asc->cs_num_max);
57
+ case PMBUS_IDLE_STATE:
38
58
+ pmbus_send8(pmdev, PMBUS_ERR_BYTE);
39
/* The memory region for the controller registers */
59
+ break;
40
memory_region_init_io(&s->mmio, OBJECT(s), &aspeed_smc_ops, s,
60
+
61
case PMBUS_CLEAR_FAULTS: /* Send Byte */
62
case PMBUS_PAGE_PLUS_WRITE: /* Block Write-only */
63
case PMBUS_STORE_DEFAULT_ALL: /* Send Byte */
41
--
64
--
42
2.39.2
65
2.35.3
43
66
44
67
diff view generated by jsdifflib
New patch
1
From: Peter Delevoryas <pdel@fb.com>
1
2
3
This commit adds a passthrough for PMBUS_IC_DEVICE_ID to allow Renesas
4
voltage regulators to return the integrated circuit device ID if they
5
would like to.
6
7
The behavior is very device specific, so it hasn't been added to the
8
general PMBUS model. Additionally, if the device ID hasn't been set,
9
then the voltage regulator will respond with the error byte value. The
10
guest error message will change slightly for IC_DEVICE_ID with this
11
commit.
12
13
Signed-off-by: Peter Delevoryas <pdel@fb.com>
14
Reviewed-by: Titus Rwantare <titusr@google.com>
15
Message-Id: <20220701000626.77395-3-me@pjd.dev>
16
Signed-off-by: Cédric Le Goater <clg@kaod.org>
17
---
18
include/hw/sensor/isl_pmbus_vr.h | 5 +++++
19
hw/sensor/isl_pmbus_vr.c | 12 ++++++++++++
20
2 files changed, 17 insertions(+)
21
22
diff --git a/include/hw/sensor/isl_pmbus_vr.h b/include/hw/sensor/isl_pmbus_vr.h
23
index XXXXXXX..XXXXXXX 100644
24
--- a/include/hw/sensor/isl_pmbus_vr.h
25
+++ b/include/hw/sensor/isl_pmbus_vr.h
26
@@ -XXX,XX +XXX,XX @@
27
#include "hw/i2c/pmbus_device.h"
28
#include "qom/object.h"
29
30
+#define TYPE_ISL69259 "isl69259"
31
#define TYPE_ISL69260 "isl69260"
32
#define TYPE_RAA228000 "raa228000"
33
#define TYPE_RAA229004 "raa229004"
34
+#define ISL_MAX_IC_DEVICE_ID_LEN 16
35
36
struct ISLState {
37
PMBusDevice parent;
38
+
39
+ uint8_t ic_device_id[ISL_MAX_IC_DEVICE_ID_LEN];
40
+ uint8_t ic_device_id_len;
41
};
42
43
OBJECT_DECLARE_SIMPLE_TYPE(ISLState, ISL69260)
44
diff --git a/hw/sensor/isl_pmbus_vr.c b/hw/sensor/isl_pmbus_vr.c
45
index XXXXXXX..XXXXXXX 100644
46
--- a/hw/sensor/isl_pmbus_vr.c
47
+++ b/hw/sensor/isl_pmbus_vr.c
48
@@ -XXX,XX +XXX,XX @@
49
50
static uint8_t isl_pmbus_vr_read_byte(PMBusDevice *pmdev)
51
{
52
+ ISLState *s = ISL69260(pmdev);
53
+
54
+ switch (pmdev->code) {
55
+ case PMBUS_IC_DEVICE_ID:
56
+ if (!s->ic_device_id_len) {
57
+ break;
58
+ }
59
+ pmbus_send(pmdev, s->ic_device_id, s->ic_device_id_len);
60
+ pmbus_idle(pmdev);
61
+ return 0;
62
+ }
63
+
64
qemu_log_mask(LOG_GUEST_ERROR,
65
"%s: reading from unsupported register: 0x%02x\n",
66
__func__, pmdev->code);
67
--
68
2.35.3
69
70
diff view generated by jsdifflib
New patch
1
From: Peter Delevoryas <pdel@fb.com>
1
2
3
This adds the ISL69259, using all the same functionality as the existing
4
ISL69260 but overriding the IC_DEVICE_ID.
5
6
Signed-off-by: Peter Delevoryas <pdel@fb.com>
7
Reviewed-by: Titus Rwantare <titusr@google.com>
8
Message-Id: <20220701000626.77395-4-me@pjd.dev>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
---
11
hw/sensor/isl_pmbus_vr.c | 28 ++++++++++++++++++++++++++++
12
1 file changed, 28 insertions(+)
13
14
diff --git a/hw/sensor/isl_pmbus_vr.c b/hw/sensor/isl_pmbus_vr.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/sensor/isl_pmbus_vr.c
17
+++ b/hw/sensor/isl_pmbus_vr.c
18
@@ -XXX,XX +XXX,XX @@ static void raa228000_exit_reset(Object *obj)
19
pmdev->pages[0].read_temperature_3 = 0;
20
}
21
22
+static void isl69259_exit_reset(Object *obj)
23
+{
24
+ ISLState *s = ISL69260(obj);
25
+ static const uint8_t ic_device_id[] = {0x04, 0x00, 0x81, 0xD2, 0x49, 0x3c};
26
+ g_assert(sizeof(ic_device_id) <= sizeof(s->ic_device_id));
27
+
28
+ isl_pmbus_vr_exit_reset(obj);
29
+
30
+ s->ic_device_id_len = sizeof(ic_device_id);
31
+ memcpy(s->ic_device_id, ic_device_id, sizeof(ic_device_id));
32
+}
33
+
34
static void isl_pmbus_vr_add_props(Object *obj, uint64_t *flags, uint8_t pages)
35
{
36
PMBusDevice *pmdev = PMBUS_DEVICE(obj);
37
@@ -XXX,XX +XXX,XX @@ static void raa229004_class_init(ObjectClass *klass, void *data)
38
isl_pmbus_vr_class_init(klass, data, 2);
39
}
40
41
+static void isl69259_class_init(ObjectClass *klass, void *data)
42
+{
43
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
44
+ DeviceClass *dc = DEVICE_CLASS(klass);
45
+ dc->desc = "Renesas ISL69259 Digital Multiphase Voltage Regulator";
46
+ rc->phases.exit = isl69259_exit_reset;
47
+ isl_pmbus_vr_class_init(klass, data, 2);
48
+}
49
+
50
+static const TypeInfo isl69259_info = {
51
+ .name = TYPE_ISL69259,
52
+ .parent = TYPE_ISL69260,
53
+ .class_init = isl69259_class_init,
54
+};
55
+
56
static const TypeInfo isl69260_info = {
57
.name = TYPE_ISL69260,
58
.parent = TYPE_PMBUS_DEVICE,
59
@@ -XXX,XX +XXX,XX @@ static const TypeInfo raa228000_info = {
60
61
static void isl_pmbus_vr_register_types(void)
62
{
63
+ type_register_static(&isl69259_info);
64
type_register_static(&isl69260_info);
65
type_register_static(&raa228000_info);
66
type_register_static(&raa229004_info);
67
--
68
2.35.3
69
70
diff view generated by jsdifflib
New patch
1
From: Peter Delevoryas <peter@pjd.dev>
1
2
3
To support multiple SoC's running simultaneously, we need a unique name for
4
each RAM region. DRAM is created by the machine, but SRAM is created by the
5
SoC, since in hardware it is part of the SoC's internals.
6
7
We need a way to uniquely identify each SRAM region though, for VM
8
migration. Since each of the SoC's CPU's has an index which identifies it
9
uniquely from other CPU's in the machine, we can use the index of any of the
10
CPU's in the SoC to uniquely identify differentiate the SRAM name from other
11
SoC SRAM's. In this change, I just elected to use the index of the first CPU
12
in each SoC.
13
14
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
15
Reviewed-by: Cédric Le Goater <clg@kaod.org>
16
Message-Id: <20220705191400.41632-3-peter@pjd.dev>
17
Signed-off-by: Cédric Le Goater <clg@kaod.org>
18
---
19
hw/arm/aspeed_ast10x0.c | 5 ++++-
20
hw/arm/aspeed_ast2600.c | 5 +++--
21
hw/arm/aspeed_soc.c | 5 +++--
22
3 files changed, 10 insertions(+), 5 deletions(-)
23
24
diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
25
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/arm/aspeed_ast10x0.c
27
+++ b/hw/arm/aspeed_ast10x0.c
28
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
29
DeviceState *armv7m;
30
Error *err = NULL;
31
int i;
32
+ g_autofree char *sram_name = NULL;
33
34
if (!clock_has_source(s->sysclk)) {
35
error_setg(errp, "sysclk clock must be wired up by the board code");
36
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
37
sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &error_abort);
38
39
/* Internal SRAM */
40
- memory_region_init_ram(&s->sram, NULL, "aspeed.sram", sc->sram_size, &err);
41
+ sram_name = g_strdup_printf("aspeed.sram.%d",
42
+ CPU(s->armv7m.cpu)->cpu_index);
43
+ memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err);
44
if (err != NULL) {
45
error_propagate(errp, err);
46
return;
47
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/arm/aspeed_ast2600.c
50
+++ b/hw/arm/aspeed_ast2600.c
51
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
52
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
53
Error *err = NULL;
54
qemu_irq irq;
55
+ g_autofree char *sram_name = NULL;
56
57
/* IO space */
58
aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io",
59
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
60
}
61
62
/* SRAM */
63
- memory_region_init_ram(&s->sram, OBJECT(dev), "aspeed.sram",
64
- sc->sram_size, &err);
65
+ sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index);
66
+ memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err);
67
if (err) {
68
error_propagate(errp, err);
69
return;
70
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
71
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/arm/aspeed_soc.c
73
+++ b/hw/arm/aspeed_soc.c
74
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
75
AspeedSoCState *s = ASPEED_SOC(dev);
76
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
77
Error *err = NULL;
78
+ g_autofree char *sram_name = NULL;
79
80
/* IO space */
81
aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io",
82
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
83
}
84
85
/* SRAM */
86
- memory_region_init_ram(&s->sram, OBJECT(dev), "aspeed.sram",
87
- sc->sram_size, &err);
88
+ sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index);
89
+ memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err);
90
if (err) {
91
error_propagate(errp, err);
92
return;
93
--
94
2.35.3
95
96
diff view generated by jsdifflib
1
The default boot address of the Aspeed SoCs is 0x0. For this reason,
1
From: Peter Delevoryas <peter@pjd.dev>
2
the FMC flash device contents are remapped by HW on the first 256MB of
2
3
the address space. In QEMU, this is currently done in the machine init
3
This change moves the code that connects the SoC UART's to serial_hd's
4
with the setup of a region alias.
4
to the machine.
5
5
6
Move this code to the SoC and introduce an extra container to prepare
6
It makes each UART a proper child member of the SoC, and then allows the
7
ground for the boot ROM region which will overlap the FMC flash
7
machine to selectively initialize the chardev for each UART with a
8
remapping.
8
serial_hd.
9
9
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
This should preserve backwards compatibility, but also allow multi-SoC
11
boards to completely change the wiring of serial devices from the
12
command line to specific SoC UART's.
13
14
This also removes the uart-default property from the SoC, since the SoC
15
doesn't need to know what UART is the "default" on the machine anymore.
16
17
I tested this using the images and commands from the previous
18
refactoring, and another test image for the ast1030:
19
20
wget https://github.com/facebook/openbmc/releases/download/v2021.49.0/fuji.mtd
21
wget https://github.com/facebook/openbmc/releases/download/v2021.49.0/wedge100.mtd
22
wget https://github.com/peterdelevoryas/OpenBIC/releases/download/oby35-cl-2022.13.01/Y35BCL.elf
23
24
Fuji uses UART1:
25
26
qemu-system-arm -machine fuji-bmc \
27
-drive file=fuji.mtd,format=raw,if=mtd \
28
-nographic
29
30
ast2600-evb uses uart-default=UART5:
31
32
qemu-system-arm -machine ast2600-evb \
33
-drive file=fuji.mtd,format=raw,if=mtd \
34
-serial null -serial mon:stdio -display none
35
36
Wedge100 uses UART3:
37
38
qemu-system-arm -machine palmetto-bmc \
39
-drive file=wedge100.mtd,format=raw,if=mtd \
40
-serial null -serial null -serial null \
41
-serial mon:stdio -display none
42
43
AST1030 EVB uses UART5:
44
45
qemu-system-arm -machine ast1030-evb \
46
-kernel Y35BCL.elf -nographic
47
48
Fixes: 6827ff20b2975 ("hw: aspeed: Init all UART's with serial devices")
49
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
50
Reviewed-by: Cédric Le Goater <clg@kaod.org>
51
Message-Id: <20220705191400.41632-4-peter@pjd.dev>
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
52
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
---
53
---
13
include/hw/arm/aspeed_soc.h | 5 +++++
54
include/hw/arm/aspeed_soc.h | 7 ++++--
14
hw/arm/aspeed.c | 13 +------------
55
hw/arm/aspeed.c | 22 +++++++++++++---
15
hw/arm/aspeed_ast2600.c | 13 +++++++++++++
56
hw/arm/aspeed_ast10x0.c | 8 +++++-
16
hw/arm/aspeed_soc.c | 14 ++++++++++++++
57
hw/arm/aspeed_ast2600.c | 8 +++++-
17
hw/arm/fby35.c | 8 +-------
58
hw/arm/aspeed_soc.c | 50 +++++++++++++++++++++++++------------
18
5 files changed, 34 insertions(+), 19 deletions(-)
59
5 files changed, 71 insertions(+), 24 deletions(-)
19
60
20
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
61
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
21
index XXXXXXX..XXXXXXX 100644
62
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/arm/aspeed_soc.h
63
--- a/include/hw/arm/aspeed_soc.h
23
+++ b/include/hw/arm/aspeed_soc.h
64
+++ b/include/hw/arm/aspeed_soc.h
65
@@ -XXX,XX +XXX,XX @@
66
#include "hw/misc/aspeed_lpc.h"
67
#include "hw/misc/unimp.h"
68
#include "hw/misc/aspeed_peci.h"
69
+#include "hw/char/serial.h"
70
71
#define ASPEED_SPIS_NUM 2
72
#define ASPEED_EHCIS_NUM 2
73
#define ASPEED_WDTS_NUM 4
74
#define ASPEED_CPUS_NUM 2
75
#define ASPEED_MACS_NUM 4
76
+#define ASPEED_UARTS_NUM 13
77
78
struct AspeedSoCState {
79
/*< private >*/
24
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
80
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
25
MemoryRegion *dram_mr;
81
AspeedSDHCIState emmc;
26
MemoryRegion dram_container;
82
AspeedLPCState lpc;
27
MemoryRegion sram;
83
AspeedPECIState peci;
28
+ MemoryRegion spi_boot_container;
84
- uint32_t uart_default;
29
+ MemoryRegion spi_boot;
85
+ SerialMM uart[ASPEED_UARTS_NUM];
30
AspeedVICState vic;
86
Clock *sysclk;
31
AspeedRtcState rtc;
87
UnimplementedDeviceState iomem;
32
AspeedTimerCtrlState timerctrl;
88
UnimplementedDeviceState video;
33
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCClass {
34
35
36
enum {
37
+ ASPEED_DEV_SPI_BOOT,
38
ASPEED_DEV_IOMEM,
39
ASPEED_DEV_UART1,
40
ASPEED_DEV_UART2,
41
@@ -XXX,XX +XXX,XX @@ enum {
89
@@ -XXX,XX +XXX,XX @@ enum {
42
ASPEED_DEV_JTAG1,
43
};
90
};
44
91
45
+#define ASPEED_SOC_SPI_BOOT_ADDR 0x0
46
+
47
qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev);
92
qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev);
48
bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp);
93
-void aspeed_soc_uart_init(AspeedSoCState *s);
49
void aspeed_soc_uart_set_chr(AspeedSoCState *s, int dev, Chardev *chr);
94
+bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp);
95
+void aspeed_soc_uart_set_chr(AspeedSoCState *s, int dev, Chardev *chr);
96
bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp);
97
void aspeed_mmio_map(AspeedSoCState *s, SysBusDevice *dev, int n, hwaddr addr);
98
void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,
50
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
99
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
51
index XXXXXXX..XXXXXXX 100644
100
index XXXXXXX..XXXXXXX 100644
52
--- a/hw/arm/aspeed.c
101
--- a/hw/arm/aspeed.c
53
+++ b/hw/arm/aspeed.c
102
+++ b/hw/arm/aspeed.c
103
@@ -XXX,XX +XXX,XX @@
104
#include "qemu/error-report.h"
105
#include "qemu/units.h"
106
#include "hw/qdev-clock.h"
107
+#include "sysemu/sysemu.h"
108
109
static struct arm_boot_info aspeed_board_binfo = {
110
.board_id = -1, /* device-tree-only board */
111
@@ -XXX,XX +XXX,XX @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo)
112
&error_fatal);
113
}
114
115
+static void connect_serial_hds_to_uarts(AspeedMachineState *bmc)
116
+{
117
+ AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(bmc);
118
+ AspeedSoCState *s = &bmc->soc;
119
+ AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
120
+
121
+ aspeed_soc_uart_set_chr(s, amc->uart_default, serial_hd(0));
122
+ for (int i = 1, uart = ASPEED_DEV_UART1; i < sc->uarts_num; i++, uart++) {
123
+ if (uart == amc->uart_default) {
124
+ continue;
125
+ }
126
+ aspeed_soc_uart_set_chr(s, uart, serial_hd(i));
127
+ }
128
+}
129
+
130
static void aspeed_machine_init(MachineState *machine)
131
{
132
AspeedMachineState *bmc = ASPEED_MACHINE(machine);
54
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
133
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
55
MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
134
object_property_set_int(OBJECT(&bmc->soc), "hw-prot-key",
56
uint64_t size = memory_region_size(&fl->mmio);
135
ASPEED_SCU_PROT_KEY, &error_abort);
57
136
}
58
- /*
137
- qdev_prop_set_uint32(DEVICE(&bmc->soc), "uart-default",
59
- * create a ROM region using the default mapping window size of
138
- amc->uart_default);
60
- * the flash module. The window size is 64MB for the AST2400
139
+ connect_serial_hds_to_uarts(bmc);
61
- * SoC and 128MB for the AST2500 SoC, which is twice as big as
140
qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
62
- * needed by the flash modules of the Aspeed machines.
141
63
- */
142
aspeed_board_init_flashes(&bmc->soc.fmc,
64
- if (ASPEED_MACHINE(machine)->mmio_exec) {
143
@@ -XXX,XX +XXX,XX @@ static void aspeed_minibmc_machine_init(MachineState *machine)
65
- memory_region_init_alias(boot_rom, NULL, "aspeed.boot_rom",
144
66
- &fl->mmio, 0, size);
145
object_property_set_link(OBJECT(&bmc->soc), "memory",
67
- memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
146
OBJECT(get_system_memory()), &error_abort);
68
- boot_rom);
147
- qdev_prop_set_uint32(DEVICE(&bmc->soc), "uart-default",
69
- } else {
148
- amc->uart_default);
70
+ if (!ASPEED_MACHINE(machine)->mmio_exec) {
149
+ connect_serial_hds_to_uarts(bmc);
71
memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom",
150
qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
72
size, &error_abort);
151
73
memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
152
aspeed_board_init_flashes(&bmc->soc.fmc,
153
diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
154
index XXXXXXX..XXXXXXX 100644
155
--- a/hw/arm/aspeed_ast10x0.c
156
+++ b/hw/arm/aspeed_ast10x0.c
157
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_init(Object *obj)
158
object_initialize_child(obj, "wdt[*]", &s->wdt[i], typename);
159
}
160
161
+ for (i = 0; i < sc->uarts_num; i++) {
162
+ object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_SERIAL_MM);
163
+ }
164
+
165
snprintf(typename, sizeof(typename), "aspeed.gpio-%s", socname);
166
object_initialize_child(obj, "gpio", &s->gpio, typename);
167
168
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp)
169
sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4));
170
171
/* UART */
172
- aspeed_soc_uart_init(s);
173
+ if (!aspeed_soc_uart_realize(s, errp)) {
174
+ return;
175
+ }
176
177
/* Timer */
178
object_property_set_link(OBJECT(&s->timerctrl), "scu", OBJECT(&s->scu),
74
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
179
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
75
index XXXXXXX..XXXXXXX 100644
180
index XXXXXXX..XXXXXXX 100644
76
--- a/hw/arm/aspeed_ast2600.c
181
--- a/hw/arm/aspeed_ast2600.c
77
+++ b/hw/arm/aspeed_ast2600.c
182
+++ b/hw/arm/aspeed_ast2600.c
78
@@ -XXX,XX +XXX,XX @@
183
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
79
#define ASPEED_SOC_DPMCU_SIZE 0x00040000
184
object_initialize_child(obj, "mii[*]", &s->mii[i], TYPE_ASPEED_MII);
80
185
}
81
static const hwaddr aspeed_soc_ast2600_memmap[] = {
186
82
+ [ASPEED_DEV_SPI_BOOT] = ASPEED_SOC_SPI_BOOT_ADDR,
187
+ for (i = 0; i < sc->uarts_num; i++) {
83
[ASPEED_DEV_SRAM] = 0x10000000,
188
+ object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_SERIAL_MM);
84
[ASPEED_DEV_DPMCU] = 0x18000000,
189
+ }
85
/* 0x16000000 0x17FFFFFF : AHB BUS do LPC Bus bridge */
190
+
191
snprintf(typename, sizeof(typename), TYPE_ASPEED_XDMA "-%s", socname);
192
object_initialize_child(obj, "xdma", &s->xdma, typename);
193
86
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
194
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
87
qemu_irq irq;
195
aspeed_soc_get_irq(s, ASPEED_DEV_ADC));
88
g_autofree char *sram_name = NULL;
196
89
197
/* UART */
90
+ /* Default boot region (SPI memory or ROMs) */
198
- aspeed_soc_uart_init(s);
91
+ memory_region_init(&s->spi_boot_container, OBJECT(s),
199
+ if (!aspeed_soc_uart_realize(s, errp)) {
92
+ "aspeed.spi_boot_container", 0x10000000);
200
+ return;
93
+ memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SPI_BOOT],
201
+ }
94
+ &s->spi_boot_container);
202
95
+
203
/* I2C */
96
/* IO space */
204
object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
97
aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io",
98
sc->memmap[ASPEED_DEV_IOMEM],
99
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
100
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
101
aspeed_soc_get_irq(s, ASPEED_DEV_FMC));
102
103
+ /* Set up an alias on the FMC CE0 region (boot default) */
104
+ MemoryRegion *fmc0_mmio = &s->fmc.flashes[0].mmio;
105
+ memory_region_init_alias(&s->spi_boot, OBJECT(s), "aspeed.spi_boot",
106
+ fmc0_mmio, 0, memory_region_size(fmc0_mmio));
107
+ memory_region_add_subregion(&s->spi_boot_container, 0x0, &s->spi_boot);
108
+
109
/* SPI */
110
for (i = 0; i < sc->spis_num; i++) {
111
object_property_set_link(OBJECT(&s->spi[i]), "dram",
112
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
205
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
113
index XXXXXXX..XXXXXXX 100644
206
index XXXXXXX..XXXXXXX 100644
114
--- a/hw/arm/aspeed_soc.c
207
--- a/hw/arm/aspeed_soc.c
115
+++ b/hw/arm/aspeed_soc.c
208
+++ b/hw/arm/aspeed_soc.c
116
@@ -XXX,XX +XXX,XX @@
209
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
117
#define ASPEED_SOC_IOMEM_SIZE 0x00200000
210
TYPE_FTGMAC100);
118
211
}
119
static const hwaddr aspeed_soc_ast2400_memmap[] = {
212
120
+ [ASPEED_DEV_SPI_BOOT] = ASPEED_SOC_SPI_BOOT_ADDR,
213
+ for (i = 0; i < sc->uarts_num; i++) {
121
[ASPEED_DEV_IOMEM] = 0x1E600000,
214
+ object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_SERIAL_MM);
122
[ASPEED_DEV_FMC] = 0x1E620000,
215
+ }
123
[ASPEED_DEV_SPI1] = 0x1E630000,
216
+
124
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2400_memmap[] = {
217
snprintf(typename, sizeof(typename), TYPE_ASPEED_XDMA "-%s", socname);
218
object_initialize_child(obj, "xdma", &s->xdma, typename);
219
220
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
221
aspeed_soc_get_irq(s, ASPEED_DEV_ADC));
222
223
/* UART */
224
- aspeed_soc_uart_init(s);
225
+ if (!aspeed_soc_uart_realize(s, errp)) {
226
+ return;
227
+ }
228
229
/* I2C */
230
object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
231
@@ -XXX,XX +XXX,XX @@ static Property aspeed_soc_properties[] = {
232
MemoryRegion *),
233
DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
234
MemoryRegion *),
235
- DEFINE_PROP_UINT32("uart-default", AspeedSoCState, uart_default,
236
- ASPEED_DEV_UART5),
237
DEFINE_PROP_END_OF_LIST(),
125
};
238
};
126
239
127
static const hwaddr aspeed_soc_ast2500_memmap[] = {
240
@@ -XXX,XX +XXX,XX @@ qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev)
128
+ [ASPEED_DEV_SPI_BOOT] = ASPEED_SOC_SPI_BOOT_ADDR,
241
return ASPEED_SOC_GET_CLASS(s)->get_irq(s, dev);
129
[ASPEED_DEV_IOMEM] = 0x1E600000,
242
}
130
[ASPEED_DEV_FMC] = 0x1E620000,
243
131
[ASPEED_DEV_SPI1] = 0x1E630000,
244
-void aspeed_soc_uart_init(AspeedSoCState *s)
132
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
245
+bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp)
133
Error *err = NULL;
246
{
134
g_autofree char *sram_name = NULL;
247
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
135
248
- int i, uart;
136
+ /* Default boot region (SPI memory or ROMs) */
137
+ memory_region_init(&s->spi_boot_container, OBJECT(s),
138
+ "aspeed.spi_boot_container", 0x10000000);
139
+ memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SPI_BOOT],
140
+ &s->spi_boot_container);
141
+
142
/* IO space */
143
aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io",
144
sc->memmap[ASPEED_DEV_IOMEM],
145
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
146
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
147
aspeed_soc_get_irq(s, ASPEED_DEV_FMC));
148
149
+ /* Set up an alias on the FMC CE0 region (boot default) */
150
+ MemoryRegion *fmc0_mmio = &s->fmc.flashes[0].mmio;
151
+ memory_region_init_alias(&s->spi_boot, OBJECT(s), "aspeed.spi_boot",
152
+ fmc0_mmio, 0, memory_region_size(fmc0_mmio));
153
+ memory_region_add_subregion(&s->spi_boot_container, 0x0, &s->spi_boot);
154
+
155
/* SPI */
156
for (i = 0; i < sc->spis_num; i++) {
157
if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
158
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
159
index XXXXXXX..XXXXXXX 100644
160
--- a/hw/arm/fby35.c
161
+++ b/hw/arm/fby35.c
162
@@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s)
163
MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
164
uint64_t size = memory_region_size(&fl->mmio);
165
166
- if (s->mmio_exec) {
167
- memory_region_init_alias(boot_rom, NULL, "aspeed.boot_rom",
168
- &fl->mmio, 0, size);
169
- memory_region_add_subregion(&s->bmc_memory, FBY35_BMC_FIRMWARE_ADDR,
170
- boot_rom);
171
- } else {
172
-
249
-
173
+ if (!s->mmio_exec) {
250
- /* Attach an 8250 to the IO space as our UART */
174
memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom",
251
- serial_mm_init(s->memory, sc->memmap[s->uart_default], 2,
175
size, &error_abort);
252
- aspeed_soc_get_irq(s, s->uart_default), 38400,
176
memory_region_add_subregion(&s->bmc_memory, FBY35_BMC_FIRMWARE_ADDR,
253
- serial_hd(0), DEVICE_LITTLE_ENDIAN);
254
- for (i = 1, uart = ASPEED_DEV_UART1; i < sc->uarts_num; i++, uart++) {
255
- if (uart == s->uart_default) {
256
- uart++;
257
+ SerialMM *smm;
258
+
259
+ for (int i = 0, uart = ASPEED_DEV_UART1; i < sc->uarts_num; i++, uart++) {
260
+ smm = &s->uart[i];
261
+
262
+ /* Chardev property is set by the machine. */
263
+ qdev_prop_set_uint8(DEVICE(smm), "regshift", 2);
264
+ qdev_prop_set_uint32(DEVICE(smm), "baudbase", 38400);
265
+ qdev_set_legacy_instance_id(DEVICE(smm), sc->memmap[uart], 2);
266
+ qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN);
267
+ if (!sysbus_realize(SYS_BUS_DEVICE(smm), errp)) {
268
+ return false;
269
}
270
- serial_mm_init(s->memory, sc->memmap[uart], 2,
271
- aspeed_soc_get_irq(s, uart), 38400,
272
- serial_hd(i), DEVICE_LITTLE_ENDIAN);
273
+
274
+ sysbus_connect_irq(SYS_BUS_DEVICE(smm), 0, aspeed_soc_get_irq(s, uart));
275
+ aspeed_mmio_map(s, SYS_BUS_DEVICE(smm), 0, sc->memmap[uart]);
276
}
277
+
278
+ return true;
279
+}
280
+
281
+void aspeed_soc_uart_set_chr(AspeedSoCState *s, int dev, Chardev *chr)
282
+{
283
+ AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
284
+ int i = dev - ASPEED_DEV_UART1;
285
+
286
+ g_assert(0 <= i && i < ARRAY_SIZE(s->uart) && i < sc->uarts_num);
287
+ qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
288
}
289
290
/*
177
--
291
--
178
2.39.2
292
2.35.3
179
293
180
294
diff view generated by jsdifflib
1
To avoid the SPI transactions fetching instructions from the FMC CE0
1
From: Peter Delevoryas <peter@pjd.dev>
2
flash device and speed up boot, a ROM can be created if a drive is
3
available.
4
2
5
Reverse the logic to allow a machine to boot without a drive, using a
3
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
6
block device instead :
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
7
5
Message-Id: <20220705191400.41632-5-peter@pjd.dev>
8
-blockdev node-name=fmc0,driver=file,filename=/path/to/flash.img \
9
-device mx66u51235f,bus=ssi.0,drive=fmc0
10
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
---
7
---
13
hw/arm/aspeed.c | 47 +++++++++++++++++++++++++++--------------------
8
include/hw/arm/aspeed_soc.h | 2 ++
14
1 file changed, 27 insertions(+), 20 deletions(-)
9
hw/arm/aspeed.c | 2 +-
10
2 files changed, 3 insertions(+), 1 deletion(-)
15
11
12
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/arm/aspeed_soc.h
15
+++ b/include/hw/arm/aspeed_soc.h
16
@@ -XXX,XX +XXX,XX @@ void aspeed_mmio_map(AspeedSoCState *s, SysBusDevice *dev, int n, hwaddr addr);
17
void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,
18
const char *name, hwaddr addr,
19
uint64_t size);
20
+void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
21
+ unsigned int count, int unit0);
22
23
#endif /* ASPEED_SOC_H */
16
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
24
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
17
index XXXXXXX..XXXXXXX 100644
25
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/aspeed.c
26
--- a/hw/arm/aspeed.c
19
+++ b/hw/arm/aspeed.c
27
+++ b/hw/arm/aspeed.c
20
@@ -XXX,XX +XXX,XX @@ static void aspeed_reset_secondary(ARMCPU *cpu,
21
cpu_set_pc(cs, info->smp_loader_start);
22
}
23
24
-#define FIRMWARE_ADDR 0x0
25
-
26
-static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
27
+static void write_boot_rom(BlockBackend *blk, hwaddr addr, size_t rom_size,
28
Error **errp)
29
{
30
- BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
31
g_autofree void *storage = NULL;
32
int64_t size;
33
34
@@ -XXX,XX +XXX,XX @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
28
@@ -XXX,XX +XXX,XX @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
35
rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr);
29
rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr);
36
}
30
}
37
31
38
+/*
32
-static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
39
+ * Create a ROM and copy the flash contents at the expected address
33
+void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
40
+ * (0x0). Boots faster than execute-in-place.
41
+ */
42
+static void aspeed_install_boot_rom(AspeedSoCState *soc, BlockBackend *blk,
43
+ uint64_t rom_size)
44
+{
45
+ MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
46
+
47
+ memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom", rom_size,
48
+ &error_abort);
49
+ memory_region_add_subregion_overlap(&soc->spi_boot_container, 0,
50
+ boot_rom, 1);
51
+ write_boot_rom(blk, ASPEED_SOC_SPI_BOOT_ADDR, rom_size, &error_abort);
52
+}
53
+
54
void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
55
unsigned int count, int unit0)
34
unsigned int count, int unit0)
56
{
35
{
57
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
58
AspeedMachineState *bmc = ASPEED_MACHINE(machine);
59
AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(machine);
60
AspeedSoCClass *sc;
61
- DriveInfo *drive0 = drive_get(IF_MTD, 0, 0);
62
int i;
36
int i;
63
NICInfo *nd = &nd_table[0];
64
65
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
66
bmc->spi_model ? bmc->spi_model : amc->spi_model,
67
1, amc->num_cs);
68
69
- /* Install first FMC flash content as a boot rom. */
70
- if (drive0) {
71
- AspeedSMCFlash *fl = &bmc->soc.fmc.flashes[0];
72
- MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
73
- uint64_t size = memory_region_size(&fl->mmio);
74
-
75
- if (!ASPEED_MACHINE(machine)->mmio_exec) {
76
- memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom",
77
- size, &error_abort);
78
- memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
79
- boot_rom);
80
- write_boot_rom(drive0, FIRMWARE_ADDR, size, &error_abort);
81
- }
82
- }
83
-
84
if (machine->kernel_filename && sc->num_cpus > 1) {
85
/* With no u-boot we must set up a boot stub for the secondary CPU */
86
MemoryRegion *smpboot = g_new(MemoryRegion, 1);
87
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
88
drive_get(IF_SD, 0, bmc->soc.sdhci.num_slots));
89
}
90
91
+ if (!bmc->mmio_exec) {
92
+ DriveInfo *mtd0 = drive_get(IF_MTD, 0, 0);
93
+
94
+ if (mtd0) {
95
+ uint64_t rom_size = memory_region_size(&bmc->soc.spi_boot);
96
+ aspeed_install_boot_rom(&bmc->soc, blk_by_legacy_dinfo(mtd0),
97
+ rom_size);
98
+ }
99
+ }
100
+
101
arm_load_kernel(ARM_CPU(first_cpu), machine, &aspeed_board_binfo);
102
}
103
104
--
37
--
105
2.39.2
38
2.35.3
106
39
107
40
diff view generated by jsdifflib
1
From: Klaus Jensen <k.jensen@samsung.com>
1
From: Peter Delevoryas <peter@pjd.dev>
2
2
3
Add an example I2C device to demonstrate how a slave may master the bus
3
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
4
and send data asynchronously to another slave.
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5
5
Message-Id: <20220705191400.41632-6-peter@pjd.dev>
6
The device will echo whatever it is sent to the device identified by the
7
first byte received.
8
9
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
10
[ clg: integrated fixes :
11
https://lore.kernel.org/qemu-devel/Y3yMKAhOkYGtnkOp@cormorant.local/ ]
12
Message-Id: <20220601210831.67259-7-its@irrelevant.dk>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
---
7
---
15
hw/misc/i2c-echo.c | 156 ++++++++++++++++++++++++++++++++++++++++++++
8
hw/arm/fby35.c | 39 +++++++++++++++++++++++++++++++++++++++
16
hw/misc/meson.build | 2 +
9
MAINTAINERS | 1 +
17
2 files changed, 158 insertions(+)
10
hw/arm/meson.build | 3 ++-
18
create mode 100644 hw/misc/i2c-echo.c
11
3 files changed, 42 insertions(+), 1 deletion(-)
12
create mode 100644 hw/arm/fby35.c
19
13
20
diff --git a/hw/misc/i2c-echo.c b/hw/misc/i2c-echo.c
14
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
21
new file mode 100644
15
new file mode 100644
22
index XXXXXXX..XXXXXXX
16
index XXXXXXX..XXXXXXX
23
--- /dev/null
17
--- /dev/null
24
+++ b/hw/misc/i2c-echo.c
18
+++ b/hw/arm/fby35.c
25
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
20
+/*
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates. (http://www.meta.com)
22
+ *
23
+ * This code is licensed under the GPL version 2 or later. See the COPYING
24
+ * file in the top-level directory.
25
+ */
26
+
26
+#include "qemu/osdep.h"
27
+#include "qemu/osdep.h"
27
+#include "qemu/timer.h"
28
+#include "hw/boards.h"
28
+#include "qemu/main-loop.h"
29
+#include "block/aio.h"
30
+#include "hw/i2c/i2c.h"
31
+
29
+
32
+#define TYPE_I2C_ECHO "i2c-echo"
30
+#define TYPE_FBY35 MACHINE_TYPE_NAME("fby35")
33
+OBJECT_DECLARE_SIMPLE_TYPE(I2CEchoState, I2C_ECHO)
31
+OBJECT_DECLARE_SIMPLE_TYPE(Fby35State, FBY35);
34
+
32
+
35
+enum i2c_echo_state {
33
+struct Fby35State {
36
+ I2C_ECHO_STATE_IDLE,
34
+ MachineState parent_obj;
37
+ I2C_ECHO_STATE_START_SEND,
38
+ I2C_ECHO_STATE_ACK,
39
+};
35
+};
40
+
36
+
41
+typedef struct I2CEchoState {
37
+static void fby35_init(MachineState *machine)
42
+ I2CSlave parent_obj;
43
+
44
+ I2CBus *bus;
45
+
46
+ enum i2c_echo_state state;
47
+ QEMUBH *bh;
48
+
49
+ unsigned int pos;
50
+ uint8_t data[3];
51
+} I2CEchoState;
52
+
53
+static void i2c_echo_bh(void *opaque)
54
+{
38
+{
55
+ I2CEchoState *state = opaque;
56
+
57
+ switch (state->state) {
58
+ case I2C_ECHO_STATE_IDLE:
59
+ return;
60
+
61
+ case I2C_ECHO_STATE_START_SEND:
62
+ if (i2c_start_send_async(state->bus, state->data[0])) {
63
+ goto release_bus;
64
+ }
65
+
66
+ state->pos++;
67
+ state->state = I2C_ECHO_STATE_ACK;
68
+ return;
69
+
70
+ case I2C_ECHO_STATE_ACK:
71
+ if (state->pos > 2) {
72
+ break;
73
+ }
74
+
75
+ if (i2c_send_async(state->bus, state->data[state->pos++])) {
76
+ break;
77
+ }
78
+
79
+ return;
80
+ }
81
+
82
+
83
+ i2c_end_transfer(state->bus);
84
+release_bus:
85
+ i2c_bus_release(state->bus);
86
+
87
+ state->state = I2C_ECHO_STATE_IDLE;
88
+}
39
+}
89
+
40
+
90
+static int i2c_echo_event(I2CSlave *s, enum i2c_event event)
41
+static void fby35_class_init(ObjectClass *oc, void *data)
91
+{
42
+{
92
+ I2CEchoState *state = I2C_ECHO(s);
43
+ MachineClass *mc = MACHINE_CLASS(oc);
93
+
44
+
94
+ switch (event) {
45
+ mc->desc = "Meta Platforms fby35";
95
+ case I2C_START_RECV:
46
+ mc->init = fby35_init;
96
+ state->pos = 0;
97
+
98
+ break;
99
+
100
+ case I2C_START_SEND:
101
+ state->pos = 0;
102
+
103
+ break;
104
+
105
+ case I2C_FINISH:
106
+ state->pos = 0;
107
+ state->state = I2C_ECHO_STATE_START_SEND;
108
+ i2c_bus_master(state->bus, state->bh);
109
+
110
+ break;
111
+
112
+ case I2C_NACK:
113
+ break;
114
+
115
+ default:
116
+ return -1;
117
+ }
118
+
119
+ return 0;
120
+}
47
+}
121
+
48
+
122
+static uint8_t i2c_echo_recv(I2CSlave *s)
49
+static const TypeInfo fby35_types[] = {
123
+{
50
+ {
124
+ I2CEchoState *state = I2C_ECHO(s);
51
+ .name = MACHINE_TYPE_NAME("fby35"),
125
+
52
+ .parent = TYPE_MACHINE,
126
+ if (state->pos > 2) {
53
+ .class_init = fby35_class_init,
127
+ return 0xff;
54
+ .instance_size = sizeof(Fby35State),
128
+ }
55
+ },
129
+
130
+ return state->data[state->pos++];
131
+}
132
+
133
+static int i2c_echo_send(I2CSlave *s, uint8_t data)
134
+{
135
+ I2CEchoState *state = I2C_ECHO(s);
136
+
137
+ if (state->pos > 2) {
138
+ return -1;
139
+ }
140
+
141
+ state->data[state->pos++] = data;
142
+
143
+ return 0;
144
+}
145
+
146
+static void i2c_echo_realize(DeviceState *dev, Error **errp)
147
+{
148
+ I2CEchoState *state = I2C_ECHO(dev);
149
+ BusState *bus = qdev_get_parent_bus(dev);
150
+
151
+ state->bus = I2C_BUS(bus);
152
+ state->bh = qemu_bh_new(i2c_echo_bh, state);
153
+
154
+ return;
155
+}
156
+
157
+static void i2c_echo_class_init(ObjectClass *oc, void *data)
158
+{
159
+ I2CSlaveClass *sc = I2C_SLAVE_CLASS(oc);
160
+ DeviceClass *dc = DEVICE_CLASS(oc);
161
+
162
+ dc->realize = i2c_echo_realize;
163
+
164
+ sc->event = i2c_echo_event;
165
+ sc->recv = i2c_echo_recv;
166
+ sc->send = i2c_echo_send;
167
+}
168
+
169
+static const TypeInfo i2c_echo = {
170
+ .name = TYPE_I2C_ECHO,
171
+ .parent = TYPE_I2C_SLAVE,
172
+ .instance_size = sizeof(I2CEchoState),
173
+ .class_init = i2c_echo_class_init,
174
+};
56
+};
175
+
57
+
176
+static void register_types(void)
58
+DEFINE_TYPES(fby35_types);
177
+{
59
diff --git a/MAINTAINERS b/MAINTAINERS
178
+ type_register_static(&i2c_echo);
179
+}
180
+
181
+type_init(register_types);
182
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
183
index XXXXXXX..XXXXXXX 100644
60
index XXXXXXX..XXXXXXX 100644
184
--- a/hw/misc/meson.build
61
--- a/MAINTAINERS
185
+++ b/hw/misc/meson.build
62
+++ b/MAINTAINERS
186
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_rng.c'))
63
@@ -XXX,XX +XXX,XX @@ F: hw/net/ftgmac100.c
187
64
F: include/hw/net/ftgmac100.h
188
softmmu_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_ahb_apb_pnp.c'))
65
F: docs/system/arm/aspeed.rst
189
66
F: tests/qtest/*aspeed*
190
+softmmu_ss.add(when: 'CONFIG_I2C', if_true: files('i2c-echo.c'))
67
+F: hw/arm/fby35.c
191
+
68
192
specific_ss.add(when: 'CONFIG_AVR_POWER', if_true: files('avr_power.c'))
69
NRF51
193
70
M: Joel Stanley <joel@jms.id.au>
194
specific_ss.add(when: 'CONFIG_MAC_VIA', if_true: files('mac_via.c'))
71
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
72
index XXXXXXX..XXXXXXX 100644
73
--- a/hw/arm/meson.build
74
+++ b/hw/arm/meson.build
75
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files(
76
'aspeed_soc.c',
77
'aspeed.c',
78
'aspeed_ast2600.c',
79
- 'aspeed_ast10x0.c'))
80
+ 'aspeed_ast10x0.c',
81
+ 'fby35.c'))
82
arm_ss.add(when: 'CONFIG_MPS2', if_true: files('mps2.c'))
83
arm_ss.add(when: 'CONFIG_MPS2', if_true: files('mps2-tz.c'))
84
arm_ss.add(when: 'CONFIG_MSF2', if_true: files('msf2-soc.c'))
195
--
85
--
196
2.39.2
86
2.35.3
197
87
198
88
diff view generated by jsdifflib
New patch
1
From: Peter Delevoryas <peter@pjd.dev>
1
2
3
You can test booting the BMC with both '-device loader' and '-drive
4
file'. This is necessary because of how the fb-openbmc boot sequence
5
works (jump to 0x20000000 after U-Boot SPL).
6
7
wget https://github.com/facebook/openbmc/releases/download/openbmc-e2294ff5d31d/fby35.mtd
8
qemu-system-arm -machine fby35 -nographic \
9
-device loader,file=fby35.mtd,addr=0,cpu-num=0 -drive file=fby35.mtd,format=raw,if=mtd
10
11
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
12
Reviewed-by: Cédric Le Goater <clg@kaod.org>
13
Message-Id: <20220705191400.41632-7-peter@pjd.dev>
14
Signed-off-by: Cédric Le Goater <clg@kaod.org>
15
---
16
hw/arm/fby35.c | 41 +++++++++++++++++++++++++++++++++++++++++
17
1 file changed, 41 insertions(+)
18
19
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
20
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/arm/fby35.c
22
+++ b/hw/arm/fby35.c
23
@@ -XXX,XX +XXX,XX @@
24
*/
25
26
#include "qemu/osdep.h"
27
+#include "qemu/units.h"
28
+#include "qapi/error.h"
29
+#include "sysemu/sysemu.h"
30
#include "hw/boards.h"
31
+#include "hw/arm/aspeed_soc.h"
32
33
#define TYPE_FBY35 MACHINE_TYPE_NAME("fby35")
34
OBJECT_DECLARE_SIMPLE_TYPE(Fby35State, FBY35);
35
36
struct Fby35State {
37
MachineState parent_obj;
38
+
39
+ MemoryRegion bmc_memory;
40
+ MemoryRegion bmc_dram;
41
+ MemoryRegion bmc_boot_rom;
42
+
43
+ AspeedSoCState bmc;
44
};
45
46
+#define FBY35_BMC_RAM_SIZE (2 * GiB)
47
+
48
+static void fby35_bmc_init(Fby35State *s)
49
+{
50
+ memory_region_init(&s->bmc_memory, OBJECT(s), "bmc-memory", UINT64_MAX);
51
+ memory_region_init_ram(&s->bmc_dram, OBJECT(s), "bmc-dram",
52
+ FBY35_BMC_RAM_SIZE, &error_abort);
53
+
54
+ object_initialize_child(OBJECT(s), "bmc", &s->bmc, "ast2600-a3");
55
+ object_property_set_int(OBJECT(&s->bmc), "ram-size", FBY35_BMC_RAM_SIZE,
56
+ &error_abort);
57
+ object_property_set_link(OBJECT(&s->bmc), "memory", OBJECT(&s->bmc_memory),
58
+ &error_abort);
59
+ object_property_set_link(OBJECT(&s->bmc), "dram", OBJECT(&s->bmc_dram),
60
+ &error_abort);
61
+ object_property_set_int(OBJECT(&s->bmc), "hw-strap1", 0x000000C0,
62
+ &error_abort);
63
+ object_property_set_int(OBJECT(&s->bmc), "hw-strap2", 0x00000003,
64
+ &error_abort);
65
+ aspeed_soc_uart_set_chr(&s->bmc, ASPEED_DEV_UART5, serial_hd(0));
66
+ qdev_realize(DEVICE(&s->bmc), NULL, &error_abort);
67
+
68
+ aspeed_board_init_flashes(&s->bmc.fmc, "n25q00", 2, 0);
69
+}
70
+
71
static void fby35_init(MachineState *machine)
72
{
73
+ Fby35State *s = FBY35(machine);
74
+
75
+ fby35_bmc_init(s);
76
}
77
78
static void fby35_class_init(ObjectClass *oc, void *data)
79
@@ -XXX,XX +XXX,XX @@ static void fby35_class_init(ObjectClass *oc, void *data)
80
81
mc->desc = "Meta Platforms fby35";
82
mc->init = fby35_init;
83
+ mc->no_floppy = 1;
84
+ mc->no_cdrom = 1;
85
+ mc->min_cpus = mc->max_cpus = mc->default_cpus = 2;
86
}
87
88
static const TypeInfo fby35_types[] = {
89
--
90
2.35.3
91
92
diff view generated by jsdifflib
1
From: Sittisak Sinprem <ssinprem@celestica.com>
1
The BMC boots from the first flash device by fetching instructions
2
from the flash contents. Add an alias region on 0x0 for this
3
purpose. There are currently performance issues with this method (TBs
4
being flushed too often), so as a faster alternative, install the
5
flash contents as a ROM in the BMC memory space.
2
6
3
Signed-off-by: Sittisak Sinprem <ssinprem@celestica.com>
7
See commit 1a15311a12fa ("hw/arm/aspeed: add a 'execute-in-place'
4
Reviewed-by: Peter Delevoryas <peter@pjd.dev>
8
property to boot directly from CE0")
5
[ clg: checkpatch issues ]
9
6
Message-Id: <167660539263.10409.9736070122710923479-1@git.sr.ht>
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
12
[ clg: blk_pread() fixes ]
13
Message-Id: <20220705191400.41632-8-peter@pjd.dev>
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
---
15
---
9
hw/nvram/eeprom_at24c.c | 30 +++++++++++++++++++++++++++---
16
hw/arm/fby35.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++
10
1 file changed, 27 insertions(+), 3 deletions(-)
17
1 file changed, 83 insertions(+)
11
18
12
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
19
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
13
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/nvram/eeprom_at24c.c
21
--- a/hw/arm/fby35.c
15
+++ b/hw/nvram/eeprom_at24c.c
22
+++ b/hw/arm/fby35.c
16
@@ -XXX,XX +XXX,XX @@ struct EEPROMState {
23
@@ -XXX,XX +XXX,XX @@
17
uint16_t cur;
24
#include "qemu/units.h"
18
/* total size in bytes */
25
#include "qapi/error.h"
19
uint32_t rsize;
26
#include "sysemu/sysemu.h"
20
+ /*
27
+#include "sysemu/block-backend.h"
21
+ * address byte number
28
#include "hw/boards.h"
22
+ * for 24c01, 24c02 size <= 256 byte, use only 1 byte
29
#include "hw/arm/aspeed_soc.h"
23
+ * otherwise size > 256, use 2 byte
30
24
+ */
31
@@ -XXX,XX +XXX,XX @@ struct Fby35State {
25
+ uint8_t asize;
32
MemoryRegion bmc_boot_rom;
33
34
AspeedSoCState bmc;
26
+
35
+
27
bool writable;
36
+ bool mmio_exec;
28
/* cells changed since last START? */
37
};
29
bool changed;
38
30
@@ -XXX,XX +XXX,XX @@ uint8_t at24c_eeprom_recv(I2CSlave *s)
39
#define FBY35_BMC_RAM_SIZE (2 * GiB)
31
EEPROMState *ee = AT24C_EE(s);
40
+#define FBY35_BMC_FIRMWARE_ADDR 0x0
32
uint8_t ret;
41
+
33
42
+static void fby35_bmc_write_boot_rom(DriveInfo *dinfo, MemoryRegion *mr,
34
- if (ee->haveaddr == 1) {
43
+ hwaddr offset, size_t rom_size,
35
+ /*
44
+ Error **errp)
36
+ * If got the byte address but not completely with address size
45
+{
37
+ * will return the invalid value
46
+ BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
38
+ */
47
+ g_autofree void *storage = NULL;
39
+ if (ee->haveaddr > 0 && ee->haveaddr < ee->asize) {
48
+ int64_t size;
40
return 0xff;
41
}
42
43
@@ -XXX,XX +XXX,XX @@ int at24c_eeprom_send(I2CSlave *s, uint8_t data)
44
{
45
EEPROMState *ee = AT24C_EE(s);
46
47
- if (ee->haveaddr < 2) {
48
+ if (ee->haveaddr < ee->asize) {
49
ee->cur <<= 8;
50
ee->cur |= data;
51
ee->haveaddr++;
52
- if (ee->haveaddr == 2) {
53
+ if (ee->haveaddr == ee->asize) {
54
ee->cur %= ee->rsize;
55
DPRINTK("Set pointer %04x\n", ee->cur);
56
}
57
@@ -XXX,XX +XXX,XX @@ static void at24c_eeprom_realize(DeviceState *dev, Error **errp)
58
}
59
DPRINTK("Reset read backing file\n");
60
}
61
+
49
+
62
+ /*
50
+ /*
63
+ * If address size didn't define with property set
51
+ * The block backend size should have already been 'validated' by
64
+ * value is 0 as default, setting it by Rom size detecting.
52
+ * the creation of the m25p80 object.
65
+ */
53
+ */
66
+ if (ee->asize == 0) {
54
+ size = blk_getlength(blk);
67
+ if (ee->rsize <= 256) {
55
+ if (size <= 0) {
68
+ ee->asize = 1;
56
+ error_setg(errp, "failed to get flash size");
57
+ return;
58
+ }
59
+
60
+ if (rom_size > size) {
61
+ rom_size = size;
62
+ }
63
+
64
+ storage = g_malloc0(rom_size);
65
+ if (blk_pread(blk, 0, rom_size, storage, 0) < 0) {
66
+ error_setg(errp, "failed to read the initial flash content");
67
+ return;
68
+ }
69
+
70
+ /* TODO: find a better way to install the ROM */
71
+ memcpy(memory_region_get_ram_ptr(mr) + offset, storage, rom_size);
72
+}
73
74
static void fby35_bmc_init(Fby35State *s)
75
{
76
+ DriveInfo *drive0 = drive_get(IF_MTD, 0, 0);
77
+
78
memory_region_init(&s->bmc_memory, OBJECT(s), "bmc-memory", UINT64_MAX);
79
memory_region_init_ram(&s->bmc_dram, OBJECT(s), "bmc-dram",
80
FBY35_BMC_RAM_SIZE, &error_abort);
81
@@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s)
82
qdev_realize(DEVICE(&s->bmc), NULL, &error_abort);
83
84
aspeed_board_init_flashes(&s->bmc.fmc, "n25q00", 2, 0);
85
+
86
+ /* Install first FMC flash content as a boot rom. */
87
+ if (drive0) {
88
+ AspeedSMCFlash *fl = &s->bmc.fmc.flashes[0];
89
+ MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
90
+ uint64_t size = memory_region_size(&fl->mmio);
91
+
92
+ if (s->mmio_exec) {
93
+ memory_region_init_alias(boot_rom, NULL, "aspeed.boot_rom",
94
+ &fl->mmio, 0, size);
95
+ memory_region_add_subregion(&s->bmc_memory, FBY35_BMC_FIRMWARE_ADDR,
96
+ boot_rom);
69
+ } else {
97
+ } else {
70
+ ee->asize = 2;
98
+
99
+ memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom",
100
+ size, &error_abort);
101
+ memory_region_add_subregion(&s->bmc_memory, FBY35_BMC_FIRMWARE_ADDR,
102
+ boot_rom);
103
+ fby35_bmc_write_boot_rom(drive0, boot_rom, FBY35_BMC_FIRMWARE_ADDR,
104
+ size, &error_abort);
71
+ }
105
+ }
72
+ }
106
+ }
73
}
107
}
74
108
75
static
109
static void fby35_init(MachineState *machine)
76
@@ -XXX,XX +XXX,XX @@ void at24c_eeprom_reset(DeviceState *state)
110
@@ -XXX,XX +XXX,XX @@ static void fby35_init(MachineState *machine)
77
111
fby35_bmc_init(s);
78
static Property at24c_eeprom_props[] = {
112
}
79
DEFINE_PROP_UINT32("rom-size", EEPROMState, rsize, 0),
113
80
+ DEFINE_PROP_UINT8("address-size", EEPROMState, asize, 0),
114
+
81
DEFINE_PROP_BOOL("writable", EEPROMState, writable, true),
115
+static bool fby35_get_mmio_exec(Object *obj, Error **errp)
82
DEFINE_PROP_DRIVE("drive", EEPROMState, blk),
116
+{
83
DEFINE_PROP_END_OF_LIST()
117
+ return FBY35(obj)->mmio_exec;
118
+}
119
+
120
+static void fby35_set_mmio_exec(Object *obj, bool value, Error **errp)
121
+{
122
+ FBY35(obj)->mmio_exec = value;
123
+}
124
+
125
+static void fby35_instance_init(Object *obj)
126
+{
127
+ FBY35(obj)->mmio_exec = false;
128
+}
129
+
130
static void fby35_class_init(ObjectClass *oc, void *data)
131
{
132
MachineClass *mc = MACHINE_CLASS(oc);
133
@@ -XXX,XX +XXX,XX @@ static void fby35_class_init(ObjectClass *oc, void *data)
134
mc->no_floppy = 1;
135
mc->no_cdrom = 1;
136
mc->min_cpus = mc->max_cpus = mc->default_cpus = 2;
137
+
138
+ object_class_property_add_bool(oc, "execute-in-place",
139
+ fby35_get_mmio_exec,
140
+ fby35_set_mmio_exec);
141
+ object_class_property_set_description(oc, "execute-in-place",
142
+ "boot directly from CE0 flash device");
143
}
144
145
static const TypeInfo fby35_types[] = {
146
@@ -XXX,XX +XXX,XX @@ static const TypeInfo fby35_types[] = {
147
.parent = TYPE_MACHINE,
148
.class_init = fby35_class_init,
149
.instance_size = sizeof(Fby35State),
150
+ .instance_init = fby35_instance_init,
151
},
152
};
153
84
--
154
--
85
2.39.2
155
2.35.3
86
156
87
157
diff view generated by jsdifflib
New patch
1
From: Peter Delevoryas <peter@pjd.dev>
1
2
3
With the BIC, the easiest way to run everything is to create two pty's
4
for each SoC and reserve stdin/stdout for the monitor:
5
6
wget https://github.com/facebook/openbmc/releases/download/openbmc-e2294ff5d31d/fby35.mtd
7
wget https://github.com/peterdelevoryas/OpenBIC/releases/download/oby35-cl-2022.13.01/Y35BCL.elf
8
qemu-system-arm -machine fby35 \
9
-drive file=fby35.mtd,format=raw,if=mtd \
10
-device loader,file=fby35.mtd,addr=0,cpu-num=0 \
11
-serial pty -serial pty -serial mon:stdio -display none -S
12
13
screen /dev/ttys0
14
screen /dev/ttys1
15
(qemu) c
16
17
This commit only adds the the first server board's Bridge IC, but in the
18
future we'll try to include the other three server board Bridge IC's
19
too.
20
21
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
22
Reviewed-by: Cédric Le Goater <clg@kaod.org>
23
Message-Id: <20220705191400.41632-9-peter@pjd.dev>
24
Signed-off-by: Cédric Le Goater <clg@kaod.org>
25
---
26
hw/arm/fby35.c | 27 ++++++++++++++++++++++++++-
27
1 file changed, 26 insertions(+), 1 deletion(-)
28
29
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/fby35.c
32
+++ b/hw/arm/fby35.c
33
@@ -XXX,XX +XXX,XX @@
34
#include "sysemu/sysemu.h"
35
#include "sysemu/block-backend.h"
36
#include "hw/boards.h"
37
+#include "hw/qdev-clock.h"
38
#include "hw/arm/aspeed_soc.h"
39
+#include "hw/arm/boot.h"
40
41
#define TYPE_FBY35 MACHINE_TYPE_NAME("fby35")
42
OBJECT_DECLARE_SIMPLE_TYPE(Fby35State, FBY35);
43
@@ -XXX,XX +XXX,XX @@ struct Fby35State {
44
MemoryRegion bmc_memory;
45
MemoryRegion bmc_dram;
46
MemoryRegion bmc_boot_rom;
47
+ MemoryRegion bic_memory;
48
+ Clock *bic_sysclk;
49
50
AspeedSoCState bmc;
51
+ AspeedSoCState bic;
52
53
bool mmio_exec;
54
};
55
@@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s)
56
}
57
}
58
59
+static void fby35_bic_init(Fby35State *s)
60
+{
61
+ s->bic_sysclk = clock_new(OBJECT(s), "SYSCLK");
62
+ clock_set_hz(s->bic_sysclk, 200000000ULL);
63
+
64
+ memory_region_init(&s->bic_memory, OBJECT(s), "bic-memory", UINT64_MAX);
65
+
66
+ object_initialize_child(OBJECT(s), "bic", &s->bic, "ast1030-a1");
67
+ qdev_connect_clock_in(DEVICE(&s->bic), "sysclk", s->bic_sysclk);
68
+ object_property_set_link(OBJECT(&s->bic), "memory", OBJECT(&s->bic_memory),
69
+ &error_abort);
70
+ aspeed_soc_uart_set_chr(&s->bic, ASPEED_DEV_UART5, serial_hd(1));
71
+ qdev_realize(DEVICE(&s->bic), NULL, &error_abort);
72
+
73
+ aspeed_board_init_flashes(&s->bic.fmc, "sst25vf032b", 2, 2);
74
+ aspeed_board_init_flashes(&s->bic.spi[0], "sst25vf032b", 2, 4);
75
+ aspeed_board_init_flashes(&s->bic.spi[1], "sst25vf032b", 2, 6);
76
+}
77
+
78
static void fby35_init(MachineState *machine)
79
{
80
Fby35State *s = FBY35(machine);
81
82
fby35_bmc_init(s);
83
+ fby35_bic_init(s);
84
}
85
86
87
@@ -XXX,XX +XXX,XX @@ static void fby35_class_init(ObjectClass *oc, void *data)
88
mc->init = fby35_init;
89
mc->no_floppy = 1;
90
mc->no_cdrom = 1;
91
- mc->min_cpus = mc->max_cpus = mc->default_cpus = 2;
92
+ mc->min_cpus = mc->max_cpus = mc->default_cpus = 3;
93
94
object_class_property_add_bool(oc, "execute-in-place",
95
fby35_get_mmio_exec,
96
--
97
2.35.3
98
99
diff view generated by jsdifflib
1
From: Karthikeyan Pasupathi <pkarthikeyan1509@gmail.com>
1
From: Peter Delevoryas <peter@pjd.dev>
2
2
3
This patch support Tiogapass in QEMU environment.
3
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
4
and introduced EEPROM BMC FRU data support "add tiogapass_bmc_fruid data"
4
Reviewed-by: Joel Stanley <joel@jms.id.au>
5
along with the machine support.
6
7
Signed-off-by: Karthikeyan Pasupathi <pkarthikeyan1509@gmail.com>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
[ clg: - commit log topic update
6
[ clg: - fixed URL links
10
- checkpatch issues
7
- Moved Facebook Yosemite section at the end of the file ]
11
- Documentation update ]
8
Message-Id: <20220705191400.41632-10-peter@pjd.dev>
12
Message-Id: <20230216184342.253868-1-pkarthikeyan1509@gmail.com>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
---
10
---
15
docs/system/arm/aspeed.rst | 1 +
11
docs/system/arm/aspeed.rst | 48 ++++++++++++++++++++++++++++++++++++++
16
hw/arm/aspeed_eeprom.h | 3 +++
12
1 file changed, 48 insertions(+)
17
hw/arm/aspeed.c | 32 ++++++++++++++++++++++++++++++++
18
hw/arm/aspeed_eeprom.c | 22 ++++++++++++++++++++++
19
4 files changed, 58 insertions(+)
20
13
21
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
14
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
22
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
23
--- a/docs/system/arm/aspeed.rst
16
--- a/docs/system/arm/aspeed.rst
24
+++ b/docs/system/arm/aspeed.rst
17
+++ b/docs/system/arm/aspeed.rst
25
@@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines :
18
@@ -XXX,XX +XXX,XX @@ To boot a kernel directly from a Zephyr build tree:
26
- ``fp5280g2-bmc`` Inspur FP5280G2 BMC
19
27
- ``g220a-bmc`` Bytedance G220A BMC
20
$ qemu-system-arm -M ast1030-evb -nographic \
28
- ``yosemitev2-bmc`` Facebook YosemiteV2 BMC
21
-kernel zephyr.elf
29
+- ``tiogapass-bmc`` Facebook Tiogapass BMC
30
31
AST2600 SoC based machines :
32
33
diff --git a/hw/arm/aspeed_eeprom.h b/hw/arm/aspeed_eeprom.h
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/aspeed_eeprom.h
36
+++ b/hw/arm/aspeed_eeprom.h
37
@@ -XXX,XX +XXX,XX @@
38
39
#include "qemu/osdep.h"
40
41
+extern const uint8_t tiogapass_bmc_fruid[];
42
+extern const size_t tiogapass_bmc_fruid_len;
43
+
22
+
44
extern const uint8_t fby35_nic_fruid[];
23
+Facebook Yosemite v3.5 Platform and CraterLake Server (``fby35``)
45
extern const uint8_t fby35_bb_fruid[];
24
+==================================================================
46
extern const uint8_t fby35_bmc_fruid[];
47
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/arm/aspeed.c
50
+++ b/hw/arm/aspeed.c
51
@@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc)
52
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), "ds1338", 0x32);
53
}
54
55
+static void tiogapass_bmc_i2c_init(AspeedMachineState *bmc)
56
+{
57
+ AspeedSoCState *soc = &bmc->soc;
58
+
25
+
59
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x54, 128 * KiB);
26
+Facebook has a series of multi-node compute server designs named
60
+ at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * KiB,
27
+Yosemite. The most recent version released was
61
+ tiogapass_bmc_fruid, tiogapass_bmc_fruid_len);
28
+`Yosemite v3 <https://www.opencompute.org/documents/ocp-yosemite-v3-platform-design-specification-1v16-pdf>`__.
62
+}
63
+
29
+
64
static void create_pca9552(AspeedSoCState *soc, int bus_id, int addr)
30
+Yosemite v3.5 is an iteration on this design, and is very similar: there's a
65
{
31
+baseboard with a BMC, and 4 server slots. The new server board design termed
66
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, bus_id),
32
+"CraterLake" includes a Bridge IC (BIC), with room for expansion boards to
67
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_romulus_class_init(ObjectClass *oc, void *data)
33
+include various compute accelerators (video, inferencing, etc). At the moment,
68
aspeed_soc_num_cpus(amc->soc_name);
34
+only the first server slot's BIC is included.
69
};
70
71
+static void aspeed_machine_tiogapass_class_init(ObjectClass *oc, void *data)
72
+{
73
+ MachineClass *mc = MACHINE_CLASS(oc);
74
+ AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
75
+
35
+
76
+ mc->desc = "Facebook Tiogapass BMC (ARM1176)";
36
+Yosemite v3.5 is itself a sled which fits into a 40U chassis, and 3 sleds
77
+ amc->soc_name = "ast2500-a1";
37
+can be fit into a chassis. See `here <https://www.opencompute.org/products/423/wiwynn-yosemite-v3-server>`__
78
+ amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
38
+for an example.
79
+ amc->hw_strap2 = 0;
80
+ amc->fmc_model = "n25q256a";
81
+ amc->spi_model = "mx25l25635e";
82
+ amc->num_cs = 2;
83
+ amc->i2c_init = tiogapass_bmc_i2c_init;
84
+ mc->default_ram_size = 1 * GiB;
85
+ mc->default_cpus = mc->min_cpus = mc->max_cpus =
86
+ aspeed_soc_num_cpus(amc->soc_name);
87
+ aspeed_soc_num_cpus(amc->soc_name);
88
+};
89
+
39
+
90
static void aspeed_machine_sonorapass_class_init(ObjectClass *oc, void *data)
40
+In this generation, the BMC is an AST2600 and each BIC is an AST1030. The BMC
91
{
41
+runs `OpenBMC <https://github.com/facebook/openbmc>`__, and the BIC runs
92
MachineClass *mc = MACHINE_CLASS(oc);
42
+`OpenBIC <https://github.com/facebook/openbic>`__.
93
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = {
94
.name = MACHINE_TYPE_NAME("tacoma-bmc"),
95
.parent = TYPE_ASPEED_MACHINE,
96
.class_init = aspeed_machine_tacoma_class_init,
97
+ }, {
98
+ .name = MACHINE_TYPE_NAME("tiogapass-bmc"),
99
+ .parent = TYPE_ASPEED_MACHINE,
100
+ .class_init = aspeed_machine_tiogapass_class_init,
101
}, {
102
.name = MACHINE_TYPE_NAME("g220a-bmc"),
103
.parent = TYPE_ASPEED_MACHINE,
104
diff --git a/hw/arm/aspeed_eeprom.c b/hw/arm/aspeed_eeprom.c
105
index XXXXXXX..XXXXXXX 100644
106
--- a/hw/arm/aspeed_eeprom.c
107
+++ b/hw/arm/aspeed_eeprom.c
108
@@ -XXX,XX +XXX,XX @@
109
110
#include "aspeed_eeprom.h"
111
112
+/* Tiogapass BMC FRU */
113
+const uint8_t tiogapass_bmc_fruid[] = {
114
+ 0x01, 0x00, 0x00, 0x01, 0x0d, 0x00, 0x00, 0xf1, 0x01, 0x0c, 0x00, 0x36,
115
+ 0xe6, 0xd0, 0xc6, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x42, 0x4d,
116
+ 0x43, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x20, 0x4d, 0x6f,
117
+ 0x64, 0x75, 0x6c, 0x65, 0xcd, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
118
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58,
119
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e,
120
+ 0x30, 0xc9, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2,
121
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
122
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc1, 0x39, 0x01, 0x0c, 0x00, 0xc6,
123
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x54, 0x69, 0x6f, 0x67, 0x61,
124
+ 0x20, 0x50, 0x61, 0x73, 0x73, 0x20, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65,
125
+ 0x32, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
126
+ 0x58, 0x58, 0x58, 0x58, 0xc4, 0x58, 0x58, 0x58, 0x32, 0xcd, 0x58, 0x58,
127
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc7,
128
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e, 0x30, 0xc9,
129
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc8, 0x43, 0x6f,
130
+ 0x6e, 0x66, 0x69, 0x67, 0x20, 0x41, 0xc1, 0x45,
131
+};
132
+
43
+
133
const uint8_t fby35_nic_fruid[] = {
44
+Firmware images can be retrieved from the Github releases or built from the
134
0x01, 0x00, 0x00, 0x01, 0x0f, 0x20, 0x00, 0xcf, 0x01, 0x0e, 0x19, 0xd7,
45
+source code, see the README's for instructions on that. This image uses the
135
0x5e, 0xcf, 0xc8, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xdd,
46
+"fby35" machine recipe from OpenBMC, and the "yv35-cl" target from OpenBIC.
136
@@ -XXX,XX +XXX,XX @@ const uint8_t yosemitev2_bmc_fruid[] = {
47
+Some reference images can also be found here:
137
0x6e, 0x66, 0x69, 0x67, 0x20, 0x41, 0xc1, 0x45,
48
+
138
};
49
+.. code-block:: bash
139
50
+
140
+const size_t tiogapass_bmc_fruid_len = sizeof(tiogapass_bmc_fruid);
51
+ $ wget https://github.com/facebook/openbmc/releases/download/openbmc-e2294ff5d31d/fby35.mtd
141
const size_t fby35_nic_fruid_len = sizeof(fby35_nic_fruid);
52
+ $ wget https://github.com/peterdelevoryas/OpenBIC/releases/download/oby35-cl-2022.13.01/Y35BCL.elf
142
const size_t fby35_bb_fruid_len = sizeof(fby35_bb_fruid);
53
+
143
const size_t fby35_bmc_fruid_len = sizeof(fby35_bmc_fruid);
54
+Since this machine has multiple SoC's, each with their own serial console, the
55
+recommended way to run it is to allocate a pseudoterminal for each serial
56
+console and let the monitor use stdio. Also, starting in a paused state is
57
+useful because it allows you to attach to the pseudoterminals before the boot
58
+process starts.
59
+
60
+.. code-block:: bash
61
+
62
+ $ qemu-system-arm -machine fby35 \
63
+ -drive file=fby35.mtd,format=raw,if=mtd \
64
+ -device loader,file=Y35BCL.elf,addr=0,cpu-num=2 \
65
+ -serial pty -serial pty -serial mon:stdio \
66
+ -display none -S
67
+ $ screen /dev/tty0 # In a separate TMUX pane, terminal window, etc.
68
+ $ screen /dev/tty1
69
+ $ (qemu) c         # Start the boot process once screen is setup.
144
--
70
--
145
2.39.2
71
2.35.3
146
72
147
73
diff view generated by jsdifflib
1
From: Karthikeyan Pasupathi <pkarthikeyan1509@gmail.com>
1
Some more controllers have been modeled recently. Reflect that in the
2
list of supported devices. New machines were also added.
2
3
3
This patch support Yosemitev2 in QEMU environment.
4
Signed-off-by: Cédric Le Goater <clg@kaod.org>
4
and introduced EEPROM BMC FRU data support "add fbyv2_bmc_fruid data"
5
Reviewed-by: Peter Delevoryas <peter@pjd.dev>
5
along with the machine support.
6
Reviewed-by: Joel Stanley <joel@jms.id.au>
6
7
Message-Id: <20220706172131.809255-1-clg@kaod.org>
7
Signed-off-by: Karthikeyan Pasupathi <pkarthikeyan1509@gmail.com>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
9
[ clg: - commit log topic update
10
- Documentation update ]
11
Message-Id: <20230216133326.216017-1-pkarthikeyan1509@gmail.com>
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
13
---
9
---
14
docs/system/arm/aspeed.rst | 1 +
10
docs/system/arm/aspeed.rst | 14 ++++++++++----
15
hw/arm/aspeed_eeprom.h | 3 +++
11
1 file changed, 10 insertions(+), 4 deletions(-)
16
hw/arm/aspeed.c | 31 +++++++++++++++++++++++++++++++
17
hw/arm/aspeed_eeprom.c | 23 +++++++++++++++++++++++
18
4 files changed, 58 insertions(+)
19
12
20
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
13
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
21
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
22
--- a/docs/system/arm/aspeed.rst
15
--- a/docs/system/arm/aspeed.rst
23
+++ b/docs/system/arm/aspeed.rst
16
+++ b/docs/system/arm/aspeed.rst
24
@@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines :
17
@@ -XXX,XX +XXX,XX @@ AST2600 SoC based machines :
25
- ``sonorapass-bmc`` OCP SonoraPass BMC
18
- ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC
26
- ``fp5280g2-bmc`` Inspur FP5280G2 BMC
19
- ``rainier-bmc`` IBM Rainier POWER10 BMC
27
- ``g220a-bmc`` Bytedance G220A BMC
20
- ``fuji-bmc`` Facebook Fuji BMC
28
+- ``yosemitev2-bmc`` Facebook YosemiteV2 BMC
21
+- ``bletchley-bmc`` Facebook Bletchley BMC
29
22
- ``fby35-bmc`` Facebook fby35 BMC
30
AST2600 SoC based machines :
23
+- ``qcom-dc-scm-v1-bmc`` Qualcomm DC-SCM V1 BMC
31
24
+- ``qcom-firework-bmc`` Qualcomm Firework BMC
32
diff --git a/hw/arm/aspeed_eeprom.h b/hw/arm/aspeed_eeprom.h
25
33
index XXXXXXX..XXXXXXX 100644
26
Supported devices
34
--- a/hw/arm/aspeed_eeprom.h
27
-----------------
35
+++ b/hw/arm/aspeed_eeprom.h
28
@@ -XXX,XX +XXX,XX @@ Supported devices
36
@@ -XXX,XX +XXX,XX @@ extern const size_t fby35_nic_fruid_len;
29
* Interrupt Controller (VIC)
37
extern const size_t fby35_bb_fruid_len;
30
* Timer Controller
38
extern const size_t fby35_bmc_fruid_len;
31
* RTC Controller
39
32
- * I2C Controller
40
+extern const uint8_t yosemitev2_bmc_fruid[];
33
+ * I2C Controller, including the new register interface of the AST2600
41
+extern const size_t yosemitev2_bmc_fruid_len;
34
* System Control Unit (SCU)
42
+
35
* SRAM mapping
43
#endif
36
* X-DMA Controller (basic interface)
44
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
37
@@ -XXX,XX +XXX,XX @@ Supported devices
45
index XXXXXXX..XXXXXXX 100644
38
* LPC Peripheral Controller (a subset of subdevices are supported)
46
--- a/hw/arm/aspeed.c
39
* Hash/Crypto Engine (HACE) - Hash support only. TODO: HMAC and RSA
47
+++ b/hw/arm/aspeed.c
40
* ADC
48
@@ -XXX,XX +XXX,XX @@ static void ast2600_evb_i2c_init(AspeedMachineState *bmc)
41
+ * Secure Boot Controller (AST2600)
49
TYPE_TMP105, 0x4d);
42
+ * eMMC Boot Controller (dummy)
50
}
43
+ * PECI Controller (minimal)
51
44
+ * I3C Controller
52
+static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc)
45
53
+{
46
54
+ AspeedSoCState *soc = &bmc->soc;
47
Missing devices
55
+
48
@@ -XXX,XX +XXX,XX @@ Missing devices
56
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x51, 128 * KiB);
49
* Super I/O Controller
57
+ at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * KiB,
50
* PCI-Express 1 Controller
58
+ yosemitev2_bmc_fruid, yosemitev2_bmc_fruid_len);
51
* Graphic Display Controller
59
+}
52
- * PECI Controller
60
+
53
* MCTP Controller
61
static void romulus_bmc_i2c_init(AspeedMachineState *bmc)
54
* Mailbox Controller
62
{
55
* Virtual UART
63
AspeedSoCState *soc = &bmc->soc;
56
* eSPI Controller
64
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data)
57
- * I3C Controller
65
aspeed_soc_num_cpus(amc->soc_name);
58
66
};
59
Boot options
67
60
------------
68
+static void aspeed_machine_yosemitev2_class_init(ObjectClass *oc, void *data)
61
@@ -XXX,XX +XXX,XX @@ Supported devices
69
+{
62
* LPC Peripheral Controller (a subset of subdevices are supported)
70
+ MachineClass *mc = MACHINE_CLASS(oc);
63
* Hash/Crypto Engine (HACE) - Hash support only. TODO: HMAC and RSA
71
+ AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
64
* ADC
72
+
65
+ * Secure Boot Controller
73
+ mc->desc = "Facebook YosemiteV2 BMC (ARM1176)";
66
+ * PECI Controller (minimal)
74
+ amc->soc_name = "ast2500-a1";
67
75
+ amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
68
76
+ amc->hw_strap2 = 0;
69
Missing devices
77
+ amc->fmc_model = "n25q256a";
70
@@ -XXX,XX +XXX,XX @@ Missing devices
78
+ amc->spi_model = "mx25l25635e";
71
79
+ amc->num_cs = 2;
72
* PWM and Fan Controller
80
+ amc->i2c_init = yosemitev2_bmc_i2c_init;
73
* Slave GPIO Controller
81
+ mc->default_ram_size = 512 * MiB;
74
- * PECI Controller
82
+ mc->default_cpus = mc->min_cpus = mc->max_cpus =
75
* Mailbox Controller
83
+ aspeed_soc_num_cpus(amc->soc_name);
76
* Virtual UART
84
+};
77
* eSPI Controller
85
+
86
static void aspeed_machine_romulus_class_init(ObjectClass *oc, void *data)
87
{
88
MachineClass *mc = MACHINE_CLASS(oc);
89
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = {
90
.name = MACHINE_TYPE_NAME("ast2600-evb"),
91
.parent = TYPE_ASPEED_MACHINE,
92
.class_init = aspeed_machine_ast2600_evb_class_init,
93
+ }, {
94
+ .name = MACHINE_TYPE_NAME("yosemitev2-bmc"),
95
+ .parent = TYPE_ASPEED_MACHINE,
96
+ .class_init = aspeed_machine_yosemitev2_class_init,
97
}, {
98
.name = MACHINE_TYPE_NAME("tacoma-bmc"),
99
.parent = TYPE_ASPEED_MACHINE,
100
diff --git a/hw/arm/aspeed_eeprom.c b/hw/arm/aspeed_eeprom.c
101
index XXXXXXX..XXXXXXX 100644
102
--- a/hw/arm/aspeed_eeprom.c
103
+++ b/hw/arm/aspeed_eeprom.c
104
@@ -XXX,XX +XXX,XX @@ const uint8_t fby35_bmc_fruid[] = {
105
0x6e, 0x66, 0x69, 0x67, 0x20, 0x41, 0xc1, 0x45,
106
};
107
108
+/* Yosemite V2 BMC FRU */
109
+const uint8_t yosemitev2_bmc_fruid[] = {
110
+ 0x01, 0x00, 0x00, 0x01, 0x0d, 0x00, 0x00, 0xf1, 0x01, 0x0c, 0x00, 0x36,
111
+ 0xe6, 0xd0, 0xc6, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x42, 0x4d,
112
+ 0x43, 0x20, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x20, 0x4d, 0x6f,
113
+ 0x64, 0x75, 0x6c, 0x65, 0xcd, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
114
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58,
115
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e,
116
+ 0x30, 0xc9, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2,
117
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
118
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc1, 0x39, 0x01, 0x0c, 0x00, 0xc6,
119
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xd2, 0x59, 0x6f, 0x73, 0x65, 0x6d,
120
+ 0x69, 0x74, 0x65, 0x20, 0x56, 0x32, 0x2e, 0x30, 0x20, 0x45, 0x56, 0x54,
121
+ 0x32, 0xce, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58,
122
+ 0x58, 0x58, 0x58, 0x58, 0xc4, 0x45, 0x56, 0x54, 0x32, 0xcd, 0x58, 0x58,
123
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc7,
124
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc3, 0x31, 0x2e, 0x30, 0xc9,
125
+ 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xc8, 0x43, 0x6f,
126
+ 0x6e, 0x66, 0x69, 0x67, 0x20, 0x41, 0xc1, 0x45,
127
+};
128
+
129
const size_t fby35_nic_fruid_len = sizeof(fby35_nic_fruid);
130
const size_t fby35_bb_fruid_len = sizeof(fby35_bb_fruid);
131
const size_t fby35_bmc_fruid_len = sizeof(fby35_bmc_fruid);
132
+
133
+const size_t yosemitev2_bmc_fruid_len = sizeof(yosemitev2_bmc_fruid);
134
--
78
--
135
2.39.2
79
2.35.3
136
80
137
81
diff view generated by jsdifflib
1
The Aspeed 2600 I2C controller supports a slave mode which can be
1
The Aspeed SDK kernel usually includes support for the lastest HW
2
tested with the I2C echo device. Test extracted from :
2
features. This is interesting to exercise QEMU and discover the gaps
3
in the models.
3
4
4
https://lists.nongnu.org/archive/html/qemu-devel/2022-06/msg00183.html
5
Add extra I2C tests for the AST2600 EVB machine to check the new
6
register interface.
5
7
6
Suggested-by: Klaus Jensen <k.jensen@samsung.com>
8
Message-Id: <20220707091239.1029561-1-clg@kaod.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
---
10
---
10
tests/avocado/machine_aspeed.py | 10 ++++++++++
11
tests/avocado/machine_aspeed.py | 68 +++++++++++++++++++++++++++++++++
11
1 file changed, 10 insertions(+)
12
1 file changed, 68 insertions(+)
12
13
13
diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py
14
diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py
14
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
15
--- a/tests/avocado/machine_aspeed.py
16
--- a/tests/avocado/machine_aspeed.py
16
+++ b/tests/avocado/machine_aspeed.py
17
+++ b/tests/avocado/machine_aspeed.py
17
@@ -XXX,XX +XXX,XX @@ def test_arm_ast2600_evb_buildroot(self):
18
@@ -XXX,XX +XXX,XX @@ def test_arm_ast2600_evb_builroot(self):
18
'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
19
exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
19
self.vm.add_args('-device',
20
20
'ds1338,bus=aspeed.i2c.bus.3,address=0x32');
21
self.do_test_arm_aspeed_buidroot_poweroff()
22
+
23
+
24
+ def do_test_arm_aspeed_sdk_start(self, image, cpu_id):
25
+ self.vm.set_console()
26
+ self.vm.add_args('-drive', 'file=' + image + ',if=mtd,format=raw',
27
+ '-net', 'nic', '-net', 'user')
28
+ self.vm.launch()
29
+
30
+ self.wait_for_console_pattern('U-Boot 2019.04')
31
+ self.wait_for_console_pattern('## Loading kernel from FIT Image')
32
+ self.wait_for_console_pattern('Starting kernel ...')
33
+ self.wait_for_console_pattern('Booting Linux on physical CPU ' + cpu_id)
34
+
35
+ def test_arm_ast2500_evb_sdk(self):
36
+ """
37
+ :avocado: tags=arch:arm
38
+ :avocado: tags=machine:ast2500-evb
39
+ """
40
+
41
+ image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
42
+ 'download/v08.01/ast2500-default-obmc.tar.gz')
43
+ image_hash = ('5375f82b4c43a79427909342a1e18b4e48bd663e38466862145d27bb358796fd')
44
+ image_path = self.fetch_asset(image_url, asset_hash=image_hash,
45
+ algorithm='sha256')
46
+ archive.extract(image_path, self.workdir)
47
+
48
+ self.do_test_arm_aspeed_sdk_start(
49
+ self.workdir + '/ast2500-default/image-bmc', '0x0')
50
+ self.wait_for_console_pattern('ast2500-default login:')
51
+
52
+ def test_arm_ast2600_evb_sdk(self):
53
+ """
54
+ :avocado: tags=arch:arm
55
+ :avocado: tags=machine:ast2600-evb
56
+ """
57
+
58
+ image_url = ('https://github.com/AspeedTech-BMC/openbmc/releases/'
59
+ 'download/v08.01/ast2600-default-obmc.tar.gz')
60
+ image_hash = ('f12ef15e8c1f03a214df3b91c814515c5e2b2f56119021398c1dbdd626817d15')
61
+ image_path = self.fetch_asset(image_url, asset_hash=image_hash,
62
+ algorithm='sha256')
63
+ archive.extract(image_path, self.workdir)
64
+
21
+ self.vm.add_args('-device',
65
+ self.vm.add_args('-device',
22
+ 'i2c-echo,bus=aspeed.i2c.bus.3,address=0x42');
66
+ 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test');
23
self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00')
67
+ self.vm.add_args('-device',
24
68
+ 'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
25
exec_command_and_wait_for_pattern(self,
69
+ self.do_test_arm_aspeed_sdk_start(
26
@@ -XXX,XX +XXX,XX @@ def test_arm_ast2600_evb_buildroot(self):
70
+ self.workdir + '/ast2600-default/image-bmc', '0xf00')
27
year = time.strftime("%Y")
71
+ self.wait_for_console_pattern('ast2600-default login:')
28
exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
72
+ exec_command_and_wait_for_pattern(self, 'root', 'Password:')
29
73
+ exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#')
74
+
30
+ exec_command_and_wait_for_pattern(self,
75
+ exec_command_and_wait_for_pattern(self,
31
+ 'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-3/new_device',
76
+ 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
32
+ 'i2c i2c-3: new_device: Instantiated device slave-24c02 at 0x64');
77
+ 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
33
+ exec_command(self, 'i2cset -y 3 0x42 0x64 0x00 0xaa i');
34
+ time.sleep(0.1)
35
+ exec_command_and_wait_for_pattern(self,
78
+ exec_command_and_wait_for_pattern(self,
36
+ 'hexdump /sys/bus/i2c/devices/3-1064/slave-eeprom',
79
+ 'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
37
+ '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff');
80
+ self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
38
self.do_test_arm_aspeed_buildroot_poweroff()
81
+ property='temperature', value=18000);
39
82
+ exec_command_and_wait_for_pattern(self,
40
83
+ 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
84
+
85
+ exec_command_and_wait_for_pattern(self,
86
+ 'echo ds1307 0x32 > /sys/class/i2c-dev/i2c-5/device/new_device',
87
+ 'i2c i2c-5: new_device: Instantiated device ds1307 at 0x32');
88
+ year = time.strftime("%Y")
89
+ exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
41
--
90
--
42
2.39.2
91
2.35.3
43
92
44
93
diff view generated by jsdifflib
New patch
1
From: Iris Chen <irischenlj@fb.com>
1
2
3
Signed-off-by: Iris Chen <irischenlj@fb.com>
4
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
5
Message-Id: <20220708164552.3462620-1-irischenlj@fb.com>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
---
8
hw/block/m25p80.c | 102 ++++++++++++++++++++++++++++++++++++++++------
9
1 file changed, 90 insertions(+), 12 deletions(-)
10
11
diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/block/m25p80.c
14
+++ b/hw/block/m25p80.c
15
@@ -XXX,XX +XXX,XX @@
16
#include "trace.h"
17
#include "qom/object.h"
18
19
-/* Fields for FlashPartInfo->flags */
20
-
21
-/* erase capabilities */
22
-#define ER_4K 1
23
-#define ER_32K 2
24
-/* set to allow the page program command to write 0s back to 1. Useful for
25
- * modelling EEPROM with SPI flash command set
26
- */
27
-#define EEPROM 0x100
28
-
29
/* 16 MiB max in 3 byte address mode */
30
#define MAX_3BYTES_SIZE 0x1000000
31
-
32
#define SPI_NOR_MAX_ID_LEN 6
33
34
+/* Fields for FlashPartInfo->flags */
35
+enum spi_flash_option_flags {
36
+ ER_4K = BIT(0),
37
+ ER_32K = BIT(1),
38
+ EEPROM = BIT(2),
39
+ HAS_SR_TB = BIT(3),
40
+ HAS_SR_BP3_BIT6 = BIT(4),
41
+};
42
+
43
typedef struct FlashPartInfo {
44
const char *part_name;
45
/*
46
@@ -XXX,XX +XXX,XX @@ static const FlashPartInfo known_devices[] = {
47
{ INFO("n25q512a11", 0x20bb20, 0, 64 << 10, 1024, ER_4K) },
48
{ INFO("n25q512a13", 0x20ba20, 0, 64 << 10, 1024, ER_4K) },
49
{ INFO("n25q128", 0x20ba18, 0, 64 << 10, 256, 0) },
50
- { INFO("n25q256a", 0x20ba19, 0, 64 << 10, 512, ER_4K) },
51
+ { INFO("n25q256a", 0x20ba19, 0, 64 << 10, 512,
52
+ ER_4K | HAS_SR_BP3_BIT6 | HAS_SR_TB) },
53
{ INFO("n25q512a", 0x20ba20, 0, 64 << 10, 1024, ER_4K) },
54
{ INFO("n25q512ax3", 0x20ba20, 0x1000, 64 << 10, 1024, ER_4K) },
55
{ INFO("mt25ql512ab", 0x20ba20, 0x1044, 64 << 10, 1024, ER_4K | ER_32K) },
56
@@ -XXX,XX +XXX,XX @@ struct Flash {
57
bool reset_enable;
58
bool quad_enable;
59
bool aai_enable;
60
+ bool block_protect0;
61
+ bool block_protect1;
62
+ bool block_protect2;
63
+ bool block_protect3;
64
+ bool top_bottom_bit;
65
bool status_register_write_disabled;
66
uint8_t ear;
67
68
@@ -XXX,XX +XXX,XX @@ void flash_write8(Flash *s, uint32_t addr, uint8_t data)
69
{
70
uint32_t page = addr / s->pi->page_size;
71
uint8_t prev = s->storage[s->cur_addr];
72
+ uint32_t block_protect_value = (s->block_protect3 << 3) |
73
+ (s->block_protect2 << 2) |
74
+ (s->block_protect1 << 1) |
75
+ (s->block_protect0 << 0);
76
77
if (!s->write_enable) {
78
qemu_log_mask(LOG_GUEST_ERROR, "M25P80: write with write protect!\n");
79
return;
80
}
81
82
+ if (block_protect_value > 0) {
83
+ uint32_t num_protected_sectors = 1 << (block_protect_value - 1);
84
+ uint32_t sector = addr / s->pi->sector_size;
85
+
86
+ /* top_bottom_bit == 0 means TOP */
87
+ if (!s->top_bottom_bit) {
88
+ if (s->pi->n_sectors <= sector + num_protected_sectors) {
89
+ qemu_log_mask(LOG_GUEST_ERROR,
90
+ "M25P80: write with write protect!\n");
91
+ return;
92
+ }
93
+ } else {
94
+ if (sector < num_protected_sectors) {
95
+ qemu_log_mask(LOG_GUEST_ERROR,
96
+ "M25P80: write with write protect!\n");
97
+ return;
98
+ }
99
+ }
100
+ }
101
+
102
if ((prev ^ data) & data) {
103
trace_m25p80_programming_zero_to_one(s, addr, prev, data);
104
}
105
@@ -XXX,XX +XXX,XX @@ static void complete_collecting_data(Flash *s)
106
break;
107
case WRSR:
108
s->status_register_write_disabled = extract32(s->data[0], 7, 1);
109
+ s->block_protect0 = extract32(s->data[0], 2, 1);
110
+ s->block_protect1 = extract32(s->data[0], 3, 1);
111
+ s->block_protect2 = extract32(s->data[0], 4, 1);
112
+ if (s->pi->flags & HAS_SR_TB) {
113
+ s->top_bottom_bit = extract32(s->data[0], 5, 1);
114
+ }
115
+ if (s->pi->flags & HAS_SR_BP3_BIT6) {
116
+ s->block_protect3 = extract32(s->data[0], 6, 1);
117
+ }
118
119
switch (get_man(s)) {
120
case MAN_SPANSION:
121
@@ -XXX,XX +XXX,XX @@ static void decode_new_cmd(Flash *s, uint32_t value)
122
case RDSR:
123
s->data[0] = (!!s->write_enable) << 1;
124
s->data[0] |= (!!s->status_register_write_disabled) << 7;
125
+ s->data[0] |= (!!s->block_protect0) << 2;
126
+ s->data[0] |= (!!s->block_protect1) << 3;
127
+ s->data[0] |= (!!s->block_protect2) << 4;
128
+ if (s->pi->flags & HAS_SR_TB) {
129
+ s->data[0] |= (!!s->top_bottom_bit) << 5;
130
+ }
131
+ if (s->pi->flags & HAS_SR_BP3_BIT6) {
132
+ s->data[0] |= (!!s->block_protect3) << 6;
133
+ }
134
135
if (get_man(s) == MAN_MACRONIX || get_man(s) == MAN_ISSI) {
136
s->data[0] |= (!!s->quad_enable) << 6;
137
@@ -XXX,XX +XXX,XX @@ static void m25p80_reset(DeviceState *d)
138
139
s->wp_level = true;
140
s->status_register_write_disabled = false;
141
+ s->block_protect0 = false;
142
+ s->block_protect1 = false;
143
+ s->block_protect2 = false;
144
+ s->block_protect3 = false;
145
+ s->top_bottom_bit = false;
146
147
reset_memory(s);
148
}
149
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m25p80_write_protect = {
150
}
151
};
152
153
+static bool m25p80_block_protect_needed(void *opaque)
154
+{
155
+ Flash *s = (Flash *)opaque;
156
+
157
+ return s->block_protect0 ||
158
+ s->block_protect1 ||
159
+ s->block_protect2 ||
160
+ s->block_protect3 ||
161
+ s->top_bottom_bit;
162
+}
163
+
164
+static const VMStateDescription vmstate_m25p80_block_protect = {
165
+ .name = "m25p80/block_protect",
166
+ .version_id = 1,
167
+ .minimum_version_id = 1,
168
+ .needed = m25p80_block_protect_needed,
169
+ .fields = (VMStateField[]) {
170
+ VMSTATE_BOOL(block_protect0, Flash),
171
+ VMSTATE_BOOL(block_protect1, Flash),
172
+ VMSTATE_BOOL(block_protect2, Flash),
173
+ VMSTATE_BOOL(block_protect3, Flash),
174
+ VMSTATE_BOOL(top_bottom_bit, Flash),
175
+ VMSTATE_END_OF_LIST()
176
+ }
177
+};
178
+
179
static const VMStateDescription vmstate_m25p80 = {
180
.name = "m25p80",
181
.version_id = 0,
182
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_m25p80 = {
183
&vmstate_m25p80_data_read_loop,
184
&vmstate_m25p80_aai_enable,
185
&vmstate_m25p80_write_protect,
186
+ &vmstate_m25p80_block_protect,
187
NULL
188
}
189
};
190
--
191
2.35.3
192
193
diff view generated by jsdifflib
New patch
1
From: Iris Chen <irischenlj@fb.com>
1
2
3
Signed-off-by: Iris Chen <irischenlj@fb.com>
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5
Message-Id: <20220627185234.1911337-3-irischenlj@fb.com>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
---
8
tests/qtest/aspeed_smc-test.c | 111 ++++++++++++++++++++++++++++++++++
9
1 file changed, 111 insertions(+)
10
11
diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qtest/aspeed_smc-test.c
14
+++ b/tests/qtest/aspeed_smc-test.c
15
@@ -XXX,XX +XXX,XX @@ static void read_page_mem(uint32_t addr, uint32_t *page)
16
}
17
}
18
19
+static void write_page_mem(uint32_t addr, uint32_t write_value)
20
+{
21
+ spi_ctrl_setmode(CTRL_WRITEMODE, PP);
22
+
23
+ for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
24
+ writel(ASPEED_FLASH_BASE + addr + i * 4, write_value);
25
+ }
26
+}
27
+
28
+static void assert_page_mem(uint32_t addr, uint32_t expected_value)
29
+{
30
+ uint32_t page[FLASH_PAGE_SIZE / 4];
31
+ read_page_mem(addr, page);
32
+ for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
33
+ g_assert_cmphex(page[i], ==, expected_value);
34
+ }
35
+}
36
+
37
static void test_erase_sector(void)
38
{
39
uint32_t some_page_addr = 0x600 * FLASH_PAGE_SIZE;
40
@@ -XXX,XX +XXX,XX @@ static void test_status_reg_write_protection(void)
41
flash_reset();
42
}
43
44
+static void test_write_block_protect(void)
45
+{
46
+ uint32_t sector_size = 65536;
47
+ uint32_t n_sectors = 512;
48
+
49
+ spi_ce_ctrl(1 << CRTL_EXTENDED0);
50
+ spi_conf(CONF_ENABLE_W0);
51
+
52
+ uint32_t bp_bits = 0b0;
53
+
54
+ for (int i = 0; i < 16; i++) {
55
+ bp_bits = ((i & 0b1000) << 3) | ((i & 0b0111) << 2);
56
+
57
+ spi_ctrl_start_user();
58
+ writeb(ASPEED_FLASH_BASE, WREN);
59
+ writeb(ASPEED_FLASH_BASE, BULK_ERASE);
60
+ writeb(ASPEED_FLASH_BASE, WREN);
61
+ writeb(ASPEED_FLASH_BASE, WRSR);
62
+ writeb(ASPEED_FLASH_BASE, bp_bits);
63
+ writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR);
64
+ writeb(ASPEED_FLASH_BASE, WREN);
65
+ spi_ctrl_stop_user();
66
+
67
+ uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0;
68
+ uint32_t protection_start = n_sectors - num_protected_sectors;
69
+ uint32_t protection_end = n_sectors;
70
+
71
+ for (int sector = 0; sector < n_sectors; sector++) {
72
+ uint32_t addr = sector * sector_size;
73
+
74
+ assert_page_mem(addr, 0xffffffff);
75
+ write_page_mem(addr, make_be32(0xabcdef12));
76
+
77
+ uint32_t expected_value = protection_start <= sector
78
+ && sector < protection_end
79
+ ? 0xffffffff : 0xabcdef12;
80
+
81
+ assert_page_mem(addr, expected_value);
82
+ }
83
+ }
84
+
85
+ flash_reset();
86
+}
87
+
88
+static void test_write_block_protect_bottom_bit(void)
89
+{
90
+ uint32_t sector_size = 65536;
91
+ uint32_t n_sectors = 512;
92
+
93
+ spi_ce_ctrl(1 << CRTL_EXTENDED0);
94
+ spi_conf(CONF_ENABLE_W0);
95
+
96
+ /* top bottom bit is enabled */
97
+ uint32_t bp_bits = 0b00100 << 3;
98
+
99
+ for (int i = 0; i < 16; i++) {
100
+ bp_bits = (((i & 0b1000) | 0b0100) << 3) | ((i & 0b0111) << 2);
101
+
102
+ spi_ctrl_start_user();
103
+ writeb(ASPEED_FLASH_BASE, WREN);
104
+ writeb(ASPEED_FLASH_BASE, BULK_ERASE);
105
+ writeb(ASPEED_FLASH_BASE, WREN);
106
+ writeb(ASPEED_FLASH_BASE, WRSR);
107
+ writeb(ASPEED_FLASH_BASE, bp_bits);
108
+ writeb(ASPEED_FLASH_BASE, EN_4BYTE_ADDR);
109
+ writeb(ASPEED_FLASH_BASE, WREN);
110
+ spi_ctrl_stop_user();
111
+
112
+ uint32_t num_protected_sectors = i ? MIN(1 << (i - 1), n_sectors) : 0;
113
+ uint32_t protection_start = 0;
114
+ uint32_t protection_end = num_protected_sectors;
115
+
116
+ for (int sector = 0; sector < n_sectors; sector++) {
117
+ uint32_t addr = sector * sector_size;
118
+
119
+ assert_page_mem(addr, 0xffffffff);
120
+ write_page_mem(addr, make_be32(0xabcdef12));
121
+
122
+ uint32_t expected_value = protection_start <= sector
123
+ && sector < protection_end
124
+ ? 0xffffffff : 0xabcdef12;
125
+
126
+ assert_page_mem(addr, expected_value);
127
+ }
128
+ }
129
+
130
+ flash_reset();
131
+}
132
+
133
static char tmp_path[] = "/tmp/qtest.m25p80.XXXXXX";
134
135
int main(int argc, char **argv)
136
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
137
qtest_add_func("/ast2400/smc/read_status_reg", test_read_status_reg);
138
qtest_add_func("/ast2400/smc/status_reg_write_protection",
139
test_status_reg_write_protection);
140
+ qtest_add_func("/ast2400/smc/write_block_protect",
141
+ test_write_block_protect);
142
+ qtest_add_func("/ast2400/smc/write_block_protect_bottom_bit",
143
+ test_write_block_protect_bottom_bit);
144
145
flash_reset();
146
ret = g_test_run();
147
--
148
2.35.3
149
150
diff view generated by jsdifflib
1
From: Dongli Zhang <dongli.zhang@oracle.com>
1
From: Peter Delevoryas <peter@pjd.dev>
2
2
3
The auto completion does not work in some cases.
3
Verify the current behavior, which is that input pins can be modified by
4
guest OS register writes.
4
5
5
Case 1.
6
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
6
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
7
1. (qemu) info reg
8
Message-Id: <20220712023219.41065-2-peter@pjd.dev>
8
2. Press 'Tab'.
9
3. It does not auto complete.
10
11
Case 2.
12
13
1. (qemu) block_resize flo
14
2. Press 'Tab'.
15
3. It does not auto complete 'floppy0'.
16
17
Since the readline_add_completion_of() may add any completion when
18
strlen(pfx) is zero, we remove the check with (name[0] == '\0') because
19
strlen() always returns zero in that case.
20
21
Fixes: 52f50b1e9f8f ("readline: Extract readline_add_completion_of() from monitor")
22
Cc: Joe Jin <joe.jin@oracle.com>
23
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
24
Tested-by: Thomas Huth <thuth@redhat.com>
25
Reviewed-by: Markus Armbruster <armbru@redhat.com>
26
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
27
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
28
---
10
---
29
monitor/hmp.c | 8 ++------
11
tests/qtest/aspeed_gpio-test.c | 27 +++++++++++++++++++++++++++
30
1 file changed, 2 insertions(+), 6 deletions(-)
12
1 file changed, 27 insertions(+)
31
13
32
diff --git a/monitor/hmp.c b/monitor/hmp.c
14
diff --git a/tests/qtest/aspeed_gpio-test.c b/tests/qtest/aspeed_gpio-test.c
33
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
34
--- a/monitor/hmp.c
16
--- a/tests/qtest/aspeed_gpio-test.c
35
+++ b/monitor/hmp.c
17
+++ b/tests/qtest/aspeed_gpio-test.c
36
@@ -XXX,XX +XXX,XX @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
18
@@ -XXX,XX +XXX,XX @@
37
}
19
#include "qapi/qmp/qdict.h"
38
memcpy(cmd, pstart, len);
20
#include "libqtest-single.h"
39
cmd[len] = '\0';
21
40
- if (name[0] == '\0') {
22
+#define AST2600_GPIO_BASE 0x1E780000
41
- readline_add_completion_of(mon->rs, name, cmd);
23
+
42
- }
24
+#define GPIO_ABCD_DATA_VALUE 0x000
43
+ readline_add_completion_of(mon->rs, name, cmd);
25
+#define GPIO_ABCD_DIRECTION 0x004
44
if (*p == '\0') {
26
+
45
break;
27
static void test_set_colocated_pins(const void *data)
46
}
28
{
47
@@ -XXX,XX +XXX,XX @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
29
QTestState *s = (QTestState *)data;
48
/* block device name completion */
30
@@ -XXX,XX +XXX,XX @@ static void test_set_colocated_pins(const void *data)
49
readline_set_completion_index(mon->rs, strlen(str));
31
g_assert(!qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV7"));
50
while ((blk = blk_next(blk)) != NULL) {
32
}
51
- if (str[0] == '\0') {
33
52
- readline_add_completion_of(mon->rs, str, blk_name(blk));
34
+static void test_set_input_pins(const void *data)
53
- }
35
+{
54
+ readline_add_completion_of(mon->rs, str, blk_name(blk));
36
+ QTestState *s = (QTestState *)data;
55
}
37
+ char name[16];
56
break;
38
+ uint32_t value;
57
case 's':
39
+
40
+ qtest_writel(s, AST2600_GPIO_BASE + GPIO_ABCD_DIRECTION, 0x00000000);
41
+ for (char c = 'A'; c <= 'D'; c++) {
42
+ for (int i = 0; i < 8; i++) {
43
+ sprintf(name, "gpio%c%d", c, i);
44
+ qtest_qom_set_bool(s, "/machine/soc/gpio", name, true);
45
+ }
46
+ }
47
+ value = qtest_readl(s, AST2600_GPIO_BASE + GPIO_ABCD_DATA_VALUE);
48
+ g_assert_cmphex(value, ==, 0xffffffff);
49
+
50
+ qtest_writel(s, AST2600_GPIO_BASE + GPIO_ABCD_DATA_VALUE, 0x00000000);
51
+ value = qtest_readl(s, AST2600_GPIO_BASE + GPIO_ABCD_DATA_VALUE);
52
+ g_assert_cmphex(value, ==, 0x00000000);
53
+}
54
+
55
int main(int argc, char **argv)
56
{
57
QTestState *s;
58
@@ -XXX,XX +XXX,XX @@ int main(int argc, char **argv)
59
s = qtest_init("-machine ast2600-evb");
60
qtest_add_data_func("/ast2600/gpio/set_colocated_pins", s,
61
test_set_colocated_pins);
62
+ qtest_add_data_func("/ast2600/gpio/set_input_pins", s, test_set_input_pins);
63
r = g_test_run();
64
qtest_quit(s);
65
58
--
66
--
59
2.39.2
67
2.35.3
60
68
61
69
diff view generated by jsdifflib
1
From: Klaus Jensen <k.jensen@samsung.com>
1
From: Peter Delevoryas <peter@pjd.dev>
2
2
3
It is not given that the current master will release the bus after a
3
Up until now, guests could modify input pins by overwriting the data
4
transfer ends. Only schedule a pending master if the bus is idle.
4
value register. The guest OS should only be allowed to modify output pin
5
values, and the QOM property setter should only be permitted to modify
6
input pins.
5
7
6
Fixes: 37fa5ca42623 ("hw/i2c: support multiple masters")
8
This change also updates the gpio input pin test to match this
7
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
9
expectation.
8
Acked-by: Corey Minyard <cminyard@mvista.com>
10
9
Message-Id: <20221116084312.35808-2-its@irrelevant.dk>
11
Andrew suggested this particularly refactoring here:
12
13
https://lore.kernel.org/qemu-devel/23523aa1-ba81-412b-92cc-8174faba3612@www.fastmail.com/
14
15
Suggested-by: Andrew Jeffery <andrew@aj.id.au>
16
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
17
Fixes: 4b7f956862dc ("hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500")
18
Reviewed-by: Cédric Le Goater <clg@kaod.org>
19
Message-Id: <20220712023219.41065-3-peter@pjd.dev>
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
20
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
---
21
---
12
include/hw/i2c/i2c.h | 2 ++
22
hw/gpio/aspeed_gpio.c | 15 ++++++++-------
13
hw/i2c/aspeed_i2c.c | 2 ++
23
tests/qtest/aspeed_gpio-test.c | 2 +-
14
hw/i2c/core.c | 37 ++++++++++++++++++++++---------------
24
2 files changed, 9 insertions(+), 8 deletions(-)
15
3 files changed, 26 insertions(+), 15 deletions(-)
16
25
17
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
26
diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
18
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
19
--- a/include/hw/i2c/i2c.h
28
--- a/hw/gpio/aspeed_gpio.c
20
+++ b/include/hw/i2c/i2c.h
29
+++ b/hw/gpio/aspeed_gpio.c
21
@@ -XXX,XX +XXX,XX @@ int i2c_start_send(I2CBus *bus, uint8_t address);
30
@@ -XXX,XX +XXX,XX @@ static ptrdiff_t aspeed_gpio_set_idx(AspeedGPIOState *s, GPIOSets *regs)
22
*/
31
}
23
int i2c_start_send_async(I2CBus *bus, uint8_t address);
32
24
33
static void aspeed_gpio_update(AspeedGPIOState *s, GPIOSets *regs,
25
+void i2c_schedule_pending_master(I2CBus *bus);
34
- uint32_t value)
26
+
35
+ uint32_t value, uint32_t mode_mask)
27
void i2c_end_transfer(I2CBus *bus);
36
{
28
void i2c_nack(I2CBus *bus);
37
uint32_t input_mask = regs->input_mask;
29
void i2c_ack(I2CBus *bus);
38
uint32_t direction = regs->direction;
30
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
39
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_update(AspeedGPIOState *s, GPIOSets *regs,
31
index XXXXXXX..XXXXXXX 100644
40
uint32_t diff;
32
--- a/hw/i2c/aspeed_i2c.c
41
int gpio;
33
+++ b/hw/i2c/aspeed_i2c.c
42
34
@@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value)
43
- diff = old ^ new;
35
}
44
+ diff = (old ^ new);
36
SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, M_STOP_CMD, 0);
45
+ diff &= mode_mask;
37
aspeed_i2c_set_state(bus, I2CD_IDLE);
46
if (diff) {
38
+
47
for (gpio = 0; gpio < ASPEED_GPIOS_PER_SET; gpio++) {
39
+ i2c_schedule_pending_master(bus->bus);
48
uint32_t mask = 1 << gpio;
49
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_set_pin_level(AspeedGPIOState *s, uint32_t set_idx,
50
value &= ~pin_mask;
40
}
51
}
41
52
42
if (aspeed_i2c_bus_pkt_mode_en(bus)) {
53
- aspeed_gpio_update(s, &s->sets[set_idx], value);
43
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
54
+ aspeed_gpio_update(s, &s->sets[set_idx], value, ~s->sets[set_idx].direction);
44
index XXXXXXX..XXXXXXX 100644
55
}
45
--- a/hw/i2c/core.c
56
46
+++ b/hw/i2c/core.c
57
/*
47
@@ -XXX,XX +XXX,XX @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv)
58
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_write_index_mode(void *opaque, hwaddr offset,
48
59
reg_value = update_value_control_source(set, set->data_value,
49
void i2c_bus_master(I2CBus *bus, QEMUBH *bh)
60
reg_value);
50
{
61
set->data_read = reg_value;
51
- if (i2c_bus_busy(bus)) {
62
- aspeed_gpio_update(s, set, reg_value);
52
- I2CPendingMaster *node = g_new(struct I2CPendingMaster, 1);
63
+ aspeed_gpio_update(s, set, reg_value, set->direction);
53
- node->bh = bh;
64
return;
54
+ I2CPendingMaster *node = g_new(struct I2CPendingMaster, 1);
65
case gpio_reg_idx_direction:
55
+ node->bh = bh;
66
reg_value = set->direction;
56
+
67
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_write_index_mode(void *opaque, hwaddr offset,
57
+ QSIMPLEQ_INSERT_TAIL(&bus->pending_masters, node, entry);
68
__func__, offset, data, reg_idx_type);
58
+}
59
+
60
+void i2c_schedule_pending_master(I2CBus *bus)
61
+{
62
+ I2CPendingMaster *node;
63
64
- QSIMPLEQ_INSERT_TAIL(&bus->pending_masters, node, entry);
65
+ if (i2c_bus_busy(bus)) {
66
+ /* someone is already controlling the bus; wait for it to release it */
67
+ return;
68
+ }
69
70
+ if (QSIMPLEQ_EMPTY(&bus->pending_masters)) {
71
return;
69
return;
72
}
70
}
73
71
- aspeed_gpio_update(s, set, set->data_value);
74
- bus->bh = bh;
72
+ aspeed_gpio_update(s, set, set->data_value, UINT32_MAX);
75
+ node = QSIMPLEQ_FIRST(&bus->pending_masters);
73
return;
76
+ bus->bh = node->bh;
77
+
78
+ QSIMPLEQ_REMOVE_HEAD(&bus->pending_masters, entry);
79
+ g_free(node);
80
+
81
qemu_bh_schedule(bus->bh);
82
}
74
}
83
75
84
void i2c_bus_release(I2CBus *bus)
76
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_write(void *opaque, hwaddr offset, uint64_t data,
85
{
77
data &= props->output;
86
bus->bh = NULL;
78
data = update_value_control_source(set, set->data_value, data);
87
+
79
set->data_read = data;
88
+ i2c_schedule_pending_master(bus);
80
- aspeed_gpio_update(s, set, data);
81
+ aspeed_gpio_update(s, set, data, set->direction);
82
return;
83
case gpio_reg_direction:
84
/*
85
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_write(void *opaque, hwaddr offset, uint64_t data,
86
PRIx64"\n", __func__, offset);
87
return;
88
}
89
- aspeed_gpio_update(s, set, set->data_value);
90
+ aspeed_gpio_update(s, set, set->data_value, UINT32_MAX);
91
return;
89
}
92
}
90
93
91
int i2c_start_recv(I2CBus *bus, uint8_t address)
94
diff --git a/tests/qtest/aspeed_gpio-test.c b/tests/qtest/aspeed_gpio-test.c
92
@@ -XXX,XX +XXX,XX @@ void i2c_end_transfer(I2CBus *bus)
95
index XXXXXXX..XXXXXXX 100644
93
g_free(node);
96
--- a/tests/qtest/aspeed_gpio-test.c
94
}
97
+++ b/tests/qtest/aspeed_gpio-test.c
95
bus->broadcast = false;
98
@@ -XXX,XX +XXX,XX @@ static void test_set_input_pins(const void *data)
96
-
99
97
- if (!QSIMPLEQ_EMPTY(&bus->pending_masters)) {
100
qtest_writel(s, AST2600_GPIO_BASE + GPIO_ABCD_DATA_VALUE, 0x00000000);
98
- I2CPendingMaster *node = QSIMPLEQ_FIRST(&bus->pending_masters);
101
value = qtest_readl(s, AST2600_GPIO_BASE + GPIO_ABCD_DATA_VALUE);
99
- bus->bh = node->bh;
102
- g_assert_cmphex(value, ==, 0x00000000);
100
-
103
+ g_assert_cmphex(value, ==, 0xffffffff);
101
- QSIMPLEQ_REMOVE_HEAD(&bus->pending_masters, entry);
102
- g_free(node);
103
-
104
- qemu_bh_schedule(bus->bh);
105
- }
106
}
104
}
107
105
108
int i2c_send(I2CBus *bus, uint8_t data)
106
int main(int argc, char **argv)
109
--
107
--
110
2.39.2
108
2.35.3
111
109
112
110
diff view generated by jsdifflib
1
From: Sittisak Sinprem <ssinprem@celestica.com>
1
From: Peter Delevoryas <peter@pjd.dev>
2
2
3
Device 24C64 the size is 64 kilobits = 8kilobyte
3
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
4
Device 24C02 the size is 2 kilobits = 256byte
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5
5
Message-Id: <20220712023219.41065-4-peter@pjd.dev>
6
Signed-off-by: Sittisak Sinprem <ssinprem@celestica.com>
7
Reviewed-by: Peter Delevoryas <peter@pjd.dev>
8
[ clg: checkpatch issues ]
9
Message-Id: <167660539263.10409.9736070122710923479-2@git.sr.ht>
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
---
7
---
12
hw/arm/aspeed.c | 36 ++++++++++++++++++++----------------
8
hw/arm/aspeed.c | 14 +++++++++++++-
13
1 file changed, 20 insertions(+), 16 deletions(-)
9
1 file changed, 13 insertions(+), 1 deletion(-)
14
10
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
11
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
16
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
17
--- a/hw/arm/aspeed.c
13
--- a/hw/arm/aspeed.c
18
+++ b/hw/arm/aspeed.c
14
+++ b/hw/arm/aspeed.c
19
@@ -XXX,XX +XXX,XX @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)
15
@@ -XXX,XX +XXX,XX @@ static void fby35_reset(MachineState *state)
20
i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4c);
16
21
i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4d);
17
qemu_devices_reset();
22
18
23
- at24c_eeprom_init(i2c[19], 0x52, 64 * KiB);
19
- /* Board ID */
24
- at24c_eeprom_init(i2c[20], 0x50, 2 * KiB);
20
+ /* Board ID: 7 (Class-1, 4 slots) */
25
- at24c_eeprom_init(i2c[22], 0x52, 2 * KiB);
21
object_property_set_bool(OBJECT(gpio), "gpioV4", true, &error_fatal);
26
+ /*
22
object_property_set_bool(OBJECT(gpio), "gpioV5", true, &error_fatal);
27
+ * EEPROM 24c64 size is 64Kbits or 8 Kbytes
23
object_property_set_bool(OBJECT(gpio), "gpioV6", true, &error_fatal);
28
+ * 24c02 size is 2Kbits or 256 bytes
24
object_property_set_bool(OBJECT(gpio), "gpioV7", false, &error_fatal);
29
+ */
25
+
30
+ at24c_eeprom_init(i2c[19], 0x52, 8 * KiB);
26
+ /* Slot presence pins, inverse polarity. (False means present) */
31
+ at24c_eeprom_init(i2c[20], 0x50, 256);
27
+ object_property_set_bool(OBJECT(gpio), "gpioH4", false, &error_fatal);
32
+ at24c_eeprom_init(i2c[22], 0x52, 256);
28
+ object_property_set_bool(OBJECT(gpio), "gpioH5", true, &error_fatal);
33
29
+ object_property_set_bool(OBJECT(gpio), "gpioH6", true, &error_fatal);
34
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x48);
30
+ object_property_set_bool(OBJECT(gpio), "gpioH7", true, &error_fatal);
35
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x49);
31
+
36
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x4a);
32
+ /* Slot 12v power pins, normal polarity. (True means powered-on) */
37
i2c_slave_create_simple(i2c[3], TYPE_TMP422, 0x4c);
33
+ object_property_set_bool(OBJECT(gpio), "gpioB2", true, &error_fatal);
38
34
+ object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
39
- at24c_eeprom_init(i2c[8], 0x51, 64 * KiB);
35
+ object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
40
+ at24c_eeprom_init(i2c[8], 0x51, 8 * KiB);
36
+ object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
41
i2c_slave_create_simple(i2c[8], TYPE_LM75, 0x4a);
37
}
42
38
43
i2c_slave_create_simple(i2c[50], TYPE_LM75, 0x4c);
39
static void aspeed_machine_fby35_class_init(ObjectClass *oc, void *data)
44
- at24c_eeprom_init(i2c[50], 0x52, 64 * KiB);
45
+ at24c_eeprom_init(i2c[50], 0x52, 8 * KiB);
46
i2c_slave_create_simple(i2c[51], TYPE_TMP75, 0x48);
47
i2c_slave_create_simple(i2c[52], TYPE_TMP75, 0x49);
48
49
i2c_slave_create_simple(i2c[59], TYPE_TMP75, 0x48);
50
i2c_slave_create_simple(i2c[60], TYPE_TMP75, 0x49);
51
52
- at24c_eeprom_init(i2c[65], 0x53, 64 * KiB);
53
+ at24c_eeprom_init(i2c[65], 0x53, 8 * KiB);
54
i2c_slave_create_simple(i2c[66], TYPE_TMP75, 0x49);
55
i2c_slave_create_simple(i2c[66], TYPE_TMP75, 0x48);
56
- at24c_eeprom_init(i2c[68], 0x52, 64 * KiB);
57
- at24c_eeprom_init(i2c[69], 0x52, 64 * KiB);
58
- at24c_eeprom_init(i2c[70], 0x52, 64 * KiB);
59
- at24c_eeprom_init(i2c[71], 0x52, 64 * KiB);
60
+ at24c_eeprom_init(i2c[68], 0x52, 8 * KiB);
61
+ at24c_eeprom_init(i2c[69], 0x52, 8 * KiB);
62
+ at24c_eeprom_init(i2c[70], 0x52, 8 * KiB);
63
+ at24c_eeprom_init(i2c[71], 0x52, 8 * KiB);
64
65
- at24c_eeprom_init(i2c[73], 0x53, 64 * KiB);
66
+ at24c_eeprom_init(i2c[73], 0x53, 8 * KiB);
67
i2c_slave_create_simple(i2c[74], TYPE_TMP75, 0x49);
68
i2c_slave_create_simple(i2c[74], TYPE_TMP75, 0x48);
69
- at24c_eeprom_init(i2c[76], 0x52, 64 * KiB);
70
- at24c_eeprom_init(i2c[77], 0x52, 64 * KiB);
71
- at24c_eeprom_init(i2c[78], 0x52, 64 * KiB);
72
- at24c_eeprom_init(i2c[79], 0x52, 64 * KiB);
73
- at24c_eeprom_init(i2c[28], 0x50, 2 * KiB);
74
+ at24c_eeprom_init(i2c[76], 0x52, 8 * KiB);
75
+ at24c_eeprom_init(i2c[77], 0x52, 8 * KiB);
76
+ at24c_eeprom_init(i2c[78], 0x52, 8 * KiB);
77
+ at24c_eeprom_init(i2c[79], 0x52, 8 * KiB);
78
+ at24c_eeprom_init(i2c[28], 0x50, 256);
79
80
for (int i = 0; i < 8; i++) {
81
at24c_eeprom_init(i2c[81 + i * 8], 0x56, 64 * KiB);
82
--
40
--
83
2.39.2
41
2.35.3
84
42
85
43
diff view generated by jsdifflib