1
The following changes since commit 8e3d85d36b77f11ad7bded3a2d48c1f0cc334f82:
1
The following changes since commit a2b5f8b8ab7b2c947823088103a40f0ff11fe06b:
2
2
3
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2022-07-12 14:12:15 +0100)
3
Merge tag 'pull-tcg-20230301' of https://gitlab.com/rth7680/qemu into staging (2023-03-01 19:19:20 +0000)
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-20220713
7
https://github.com/legoater/qemu/ tags/pull-aspeed-20230302
8
8
9
for you to fetch changes up to 053b2ee5629d1b822127cc454634ec272624bab2:
9
for you to fetch changes up to b22a2d409b1acfdf0d63d1bb3595194ceb3d94da:
10
10
11
aspeed: Add fby35-bmc slot GPIO's (2022-07-13 08:16:46 +0200)
11
aspeed/smc: Replace SysBus IRQs with GPIO lines (2023-03-02 13:57:50 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
aspeed queue:
14
aspeed queue:
15
15
16
* New ISL69259 device model
16
* fix for the Aspeed I2C slave mode
17
* New fby35 multi-SoC machine (AST1030 BIC + AST2600 BMC)
17
* a new I2C echo device from Klaus and its associated test in avocado.
18
* Aspeed GPIO fixes
18
* initial SoC cleanups to allow the use of block devices instead of
19
* Extension of m25p80 with write protect bits
19
drives on the command line.
20
* More avocado tests using the Aspeed SDK
20
* new facebook machines and eeprom fixes for the Fuji
21
* readline fix
21
22
22
----------------------------------------------------------------
23
----------------------------------------------------------------
23
Cédric Le Goater (3):
24
Cédric Le Goater (4):
24
aspeed: fby35: Add a bootrom for the BMC
25
tests/avocado/machine_aspeed.py: Add an I2C slave test
25
docs: aspeed: Minor updates
26
aspeed: Introduce a spi_boot region under the SoC
26
test/avocado/machine_aspeed.py: Add SDK tests
27
aspeed: Add a boot_rom overlap region in the SoC spi_boot container
28
aspeed/smc: Replace SysBus IRQs with GPIO lines
27
29
28
Iris Chen (2):
30
Dongli Zhang (1):
29
hw: m25p80: Add Block Protect and Top Bottom bits for write protect
31
readline: fix hmp completion issue
30
hw: m25p80: add tests for BP and TB bit write protect
31
32
32
Joel Stanley (1):
33
Karthikeyan Pasupathi (2):
33
aspeed: sbc: Allow per-machine settings
34
hw/arm/aspeed: Adding new machine Yosemitev2 in QEMU
35
hw/arm/aspeed: Adding new machine Tiogapass in QEMU
34
36
35
Peter Delevoryas (13):
37
Klaus Jensen (2):
36
hw/i2c/pmbus: Add idle state to return 0xff's
38
hw/i2c: only schedule pending master when bus is idle
37
hw/sensor: Add IC_DEVICE_ID to ISL voltage regulators
39
hw/misc: add a toy i2c echo device
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
49
40
50
docs/system/arm/aspeed.rst | 62 ++++++++++++-
41
Sittisak Sinprem (2):
51
include/hw/arm/aspeed_soc.h | 9 +-
42
hw/at24c : modify at24c to support 1 byte address mode
52
include/hw/i2c/pmbus_device.h | 7 ++
43
aspeed/fuji : correct the eeprom size
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
72
44
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
Deleted patch
1
From: Joel Stanley <joel@jms.id.au>
2
1
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
Deleted patch
1
From: Peter Delevoryas <pdel@fb.com>
2
1
3
Signed-off-by: Peter Delevoryas <pdel@fb.com>
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>
7
---
8
include/hw/i2c/pmbus_device.h | 7 +++++++
9
hw/i2c/pmbus_device.c | 9 +++++++++
10
2 files changed, 16 insertions(+)
11
12
diff --git a/include/hw/i2c/pmbus_device.h b/include/hw/i2c/pmbus_device.h
13
index XXXXXXX..XXXXXXX 100644
14
--- a/include/hw/i2c/pmbus_device.h
15
+++ b/include/hw/i2c/pmbus_device.h
16
@@ -XXX,XX +XXX,XX @@ enum pmbus_registers {
17
PMBUS_MFR_MAX_TEMP_1 = 0xC0, /* R/W word */
18
PMBUS_MFR_MAX_TEMP_2 = 0xC1, /* R/W word */
19
PMBUS_MFR_MAX_TEMP_3 = 0xC2, /* R/W word */
20
+ PMBUS_IDLE_STATE = 0xFF,
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)
42
}
43
}
44
45
+void pmbus_idle(PMBusDevice *pmdev)
46
+{
47
+ pmdev->code = PMBUS_IDLE_STATE;
48
+}
49
+
50
/* assert the status_cml error upon receipt of malformed command */
51
static void pmbus_cml_error(PMBusDevice *pmdev)
52
{
53
@@ -XXX,XX +XXX,XX @@ static uint8_t pmbus_receive_byte(SMBusDevice *smd)
54
}
55
break;
56
57
+ case PMBUS_IDLE_STATE:
58
+ pmbus_send8(pmdev, PMBUS_ERR_BYTE);
59
+ break;
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 */
64
--
65
2.35.3
66
67
diff view generated by jsdifflib
Deleted patch
1
From: Peter Delevoryas <pdel@fb.com>
2
1
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
Deleted patch
1
From: Peter Delevoryas <pdel@fb.com>
2
1
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
Deleted patch
1
From: Peter Delevoryas <peter@pjd.dev>
2
1
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
From: Peter Delevoryas <peter@pjd.dev>
1
From: Dongli Zhang <dongli.zhang@oracle.com>
2
2
3
Up until now, guests could modify input pins by overwriting the data
3
The auto completion does not work in some cases.
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.
7
4
8
This change also updates the gpio input pin test to match this
5
Case 1.
9
expectation.
10
6
11
Andrew suggested this particularly refactoring here:
7
1. (qemu) info reg
8
2. Press 'Tab'.
9
3. It does not auto complete.
12
10
13
https://lore.kernel.org/qemu-devel/23523aa1-ba81-412b-92cc-8174faba3612@www.fastmail.com/
11
Case 2.
14
12
15
Suggested-by: Andrew Jeffery <andrew@aj.id.au>
13
1. (qemu) block_resize flo
16
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
14
2. Press 'Tab'.
17
Fixes: 4b7f956862dc ("hw/gpio: Add basic Aspeed GPIO model for AST2400 and AST2500")
15
3. It does not auto complete 'floppy0'.
18
Reviewed-by: Cédric Le Goater <clg@kaod.org>
16
19
Message-Id: <20220712023219.41065-3-peter@pjd.dev>
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>
20
Signed-off-by: Cédric Le Goater <clg@kaod.org>
27
Signed-off-by: Cédric Le Goater <clg@kaod.org>
21
---
28
---
22
hw/gpio/aspeed_gpio.c | 15 ++++++++-------
29
monitor/hmp.c | 8 ++------
23
tests/qtest/aspeed_gpio-test.c | 2 +-
30
1 file changed, 2 insertions(+), 6 deletions(-)
24
2 files changed, 9 insertions(+), 8 deletions(-)
25
31
26
diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c
32
diff --git a/monitor/hmp.c b/monitor/hmp.c
27
index XXXXXXX..XXXXXXX 100644
33
index XXXXXXX..XXXXXXX 100644
28
--- a/hw/gpio/aspeed_gpio.c
34
--- a/monitor/hmp.c
29
+++ b/hw/gpio/aspeed_gpio.c
35
+++ b/monitor/hmp.c
30
@@ -XXX,XX +XXX,XX @@ static ptrdiff_t aspeed_gpio_set_idx(AspeedGPIOState *s, GPIOSets *regs)
36
@@ -XXX,XX +XXX,XX @@ static void cmd_completion(MonitorHMP *mon, const char *name, const char *list)
31
}
37
}
32
38
memcpy(cmd, pstart, len);
33
static void aspeed_gpio_update(AspeedGPIOState *s, GPIOSets *regs,
39
cmd[len] = '\0';
34
- uint32_t value)
40
- if (name[0] == '\0') {
35
+ uint32_t value, uint32_t mode_mask)
41
- readline_add_completion_of(mon->rs, name, cmd);
36
{
42
- }
37
uint32_t input_mask = regs->input_mask;
43
+ readline_add_completion_of(mon->rs, name, cmd);
38
uint32_t direction = regs->direction;
44
if (*p == '\0') {
39
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_update(AspeedGPIOState *s, GPIOSets *regs,
45
break;
40
uint32_t diff;
46
}
41
int gpio;
47
@@ -XXX,XX +XXX,XX @@ static void monitor_find_completion_by_table(MonitorHMP *mon,
42
48
/* block device name completion */
43
- diff = old ^ new;
49
readline_set_completion_index(mon->rs, strlen(str));
44
+ diff = (old ^ new);
50
while ((blk = blk_next(blk)) != NULL) {
45
+ diff &= mode_mask;
51
- if (str[0] == '\0') {
46
if (diff) {
52
- readline_add_completion_of(mon->rs, str, blk_name(blk));
47
for (gpio = 0; gpio < ASPEED_GPIOS_PER_SET; gpio++) {
53
- }
48
uint32_t mask = 1 << gpio;
54
+ readline_add_completion_of(mon->rs, str, blk_name(blk));
49
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_set_pin_level(AspeedGPIOState *s, uint32_t set_idx,
55
}
50
value &= ~pin_mask;
56
break;
51
}
57
case 's':
52
53
- aspeed_gpio_update(s, &s->sets[set_idx], value);
54
+ aspeed_gpio_update(s, &s->sets[set_idx], value, ~s->sets[set_idx].direction);
55
}
56
57
/*
58
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_write_index_mode(void *opaque, hwaddr offset,
59
reg_value = update_value_control_source(set, set->data_value,
60
reg_value);
61
set->data_read = reg_value;
62
- aspeed_gpio_update(s, set, reg_value);
63
+ aspeed_gpio_update(s, set, reg_value, set->direction);
64
return;
65
case gpio_reg_idx_direction:
66
reg_value = set->direction;
67
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_write_index_mode(void *opaque, hwaddr offset,
68
__func__, offset, data, reg_idx_type);
69
return;
70
}
71
- aspeed_gpio_update(s, set, set->data_value);
72
+ aspeed_gpio_update(s, set, set->data_value, UINT32_MAX);
73
return;
74
}
75
76
@@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_write(void *opaque, hwaddr offset, uint64_t data,
77
data &= props->output;
78
data = update_value_control_source(set, set->data_value, data);
79
set->data_read = data;
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;
92
}
93
94
diff --git a/tests/qtest/aspeed_gpio-test.c b/tests/qtest/aspeed_gpio-test.c
95
index XXXXXXX..XXXXXXX 100644
96
--- a/tests/qtest/aspeed_gpio-test.c
97
+++ b/tests/qtest/aspeed_gpio-test.c
98
@@ -XXX,XX +XXX,XX @@ static void test_set_input_pins(const void *data)
99
100
qtest_writel(s, AST2600_GPIO_BASE + GPIO_ABCD_DATA_VALUE, 0x00000000);
101
value = qtest_readl(s, AST2600_GPIO_BASE + GPIO_ABCD_DATA_VALUE);
102
- g_assert_cmphex(value, ==, 0x00000000);
103
+ g_assert_cmphex(value, ==, 0xffffffff);
104
}
105
106
int main(int argc, char **argv)
107
--
58
--
108
2.35.3
59
2.39.2
109
60
110
61
diff view generated by jsdifflib
1
From: Peter Delevoryas <peter@pjd.dev>
1
From: Klaus Jensen <k.jensen@samsung.com>
2
2
3
You can test booting the BMC with both '-device loader' and '-drive
3
It is not given that the current master will release the bus after a
4
file'. This is necessary because of how the fb-openbmc boot sequence
4
transfer ends. Only schedule a pending master if the bus is idle.
5
works (jump to 0x20000000 after U-Boot SPL).
6
5
7
wget https://github.com/facebook/openbmc/releases/download/openbmc-e2294ff5d31d/fby35.mtd
6
Fixes: 37fa5ca42623 ("hw/i2c: support multiple masters")
8
qemu-system-arm -machine fby35 -nographic \
7
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
9
-device loader,file=fby35.mtd,addr=0,cpu-num=0 -drive file=fby35.mtd,format=raw,if=mtd
8
Acked-by: Corey Minyard <cminyard@mvista.com>
10
9
Message-Id: <20221116084312.35808-2-its@irrelevant.dk>
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>
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
15
---
11
---
16
hw/arm/fby35.c | 41 +++++++++++++++++++++++++++++++++++++++++
12
include/hw/i2c/i2c.h | 2 ++
17
1 file changed, 41 insertions(+)
13
hw/i2c/aspeed_i2c.c | 2 ++
14
hw/i2c/core.c | 37 ++++++++++++++++++++++---------------
15
3 files changed, 26 insertions(+), 15 deletions(-)
18
16
19
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
17
diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/arm/fby35.c
19
--- a/include/hw/i2c/i2c.h
22
+++ b/hw/arm/fby35.c
20
+++ b/include/hw/i2c/i2c.h
23
@@ -XXX,XX +XXX,XX @@
21
@@ -XXX,XX +XXX,XX @@ int i2c_start_send(I2CBus *bus, uint8_t address);
24
*/
22
*/
25
23
int i2c_start_send_async(I2CBus *bus, uint8_t address);
26
#include "qemu/osdep.h"
24
27
+#include "qemu/units.h"
25
+void i2c_schedule_pending_master(I2CBus *bus);
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
+
26
+
39
+ MemoryRegion bmc_memory;
27
void i2c_end_transfer(I2CBus *bus);
40
+ MemoryRegion bmc_dram;
28
void i2c_nack(I2CBus *bus);
41
+ MemoryRegion bmc_boot_rom;
29
void i2c_ack(I2CBus *bus);
30
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
31
index XXXXXXX..XXXXXXX 100644
32
--- a/hw/i2c/aspeed_i2c.c
33
+++ b/hw/i2c/aspeed_i2c.c
34
@@ -XXX,XX +XXX,XX @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value)
35
}
36
SHARED_ARRAY_FIELD_DP32(bus->regs, reg_cmd, M_STOP_CMD, 0);
37
aspeed_i2c_set_state(bus, I2CD_IDLE);
42
+
38
+
43
+ AspeedSoCState bmc;
39
+ i2c_schedule_pending_master(bus->bus);
44
};
40
}
45
41
46
+#define FBY35_BMC_RAM_SIZE (2 * GiB)
42
if (aspeed_i2c_bus_pkt_mode_en(bus)) {
43
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/i2c/core.c
46
+++ b/hw/i2c/core.c
47
@@ -XXX,XX +XXX,XX @@ int i2c_start_transfer(I2CBus *bus, uint8_t address, bool is_recv)
48
49
void i2c_bus_master(I2CBus *bus, QEMUBH *bh)
50
{
51
- if (i2c_bus_busy(bus)) {
52
- I2CPendingMaster *node = g_new(struct I2CPendingMaster, 1);
53
- node->bh = bh;
54
+ I2CPendingMaster *node = g_new(struct I2CPendingMaster, 1);
55
+ node->bh = bh;
47
+
56
+
48
+static void fby35_bmc_init(Fby35State *s)
57
+ QSIMPLEQ_INSERT_TAIL(&bus->pending_masters, node, entry);
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
+}
58
+}
70
+
59
+
71
static void fby35_init(MachineState *machine)
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;
72
}
73
74
- bus->bh = bh;
75
+ node = QSIMPLEQ_FIRST(&bus->pending_masters);
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
}
83
84
void i2c_bus_release(I2CBus *bus)
72
{
85
{
73
+ Fby35State *s = FBY35(machine);
86
bus->bh = NULL;
74
+
87
+
75
+ fby35_bmc_init(s);
88
+ i2c_schedule_pending_master(bus);
76
}
89
}
77
90
78
static void fby35_class_init(ObjectClass *oc, void *data)
91
int i2c_start_recv(I2CBus *bus, uint8_t address)
79
@@ -XXX,XX +XXX,XX @@ static void fby35_class_init(ObjectClass *oc, void *data)
92
@@ -XXX,XX +XXX,XX @@ void i2c_end_transfer(I2CBus *bus)
80
93
g_free(node);
81
mc->desc = "Meta Platforms fby35";
94
}
82
mc->init = fby35_init;
95
bus->broadcast = false;
83
+ mc->no_floppy = 1;
96
-
84
+ mc->no_cdrom = 1;
97
- if (!QSIMPLEQ_EMPTY(&bus->pending_masters)) {
85
+ mc->min_cpus = mc->max_cpus = mc->default_cpus = 2;
98
- I2CPendingMaster *node = QSIMPLEQ_FIRST(&bus->pending_masters);
99
- bus->bh = node->bh;
100
-
101
- QSIMPLEQ_REMOVE_HEAD(&bus->pending_masters, entry);
102
- g_free(node);
103
-
104
- qemu_bh_schedule(bus->bh);
105
- }
86
}
106
}
87
107
88
static const TypeInfo fby35_types[] = {
108
int i2c_send(I2CBus *bus, uint8_t data)
89
--
109
--
90
2.35.3
110
2.39.2
91
111
92
112
diff view generated by jsdifflib
1
From: Peter Delevoryas <peter@pjd.dev>
1
From: Klaus Jensen <k.jensen@samsung.com>
2
2
3
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
3
Add an example I2C device to demonstrate how a slave may master the bus
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
4
and send data asynchronously to another slave.
5
Message-Id: <20220705191400.41632-6-peter@pjd.dev>
5
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>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
---
14
---
8
hw/arm/fby35.c | 39 +++++++++++++++++++++++++++++++++++++++
15
hw/misc/i2c-echo.c | 156 ++++++++++++++++++++++++++++++++++++++++++++
9
MAINTAINERS | 1 +
16
hw/misc/meson.build | 2 +
10
hw/arm/meson.build | 3 ++-
17
2 files changed, 158 insertions(+)
11
3 files changed, 42 insertions(+), 1 deletion(-)
18
create mode 100644 hw/misc/i2c-echo.c
12
create mode 100644 hw/arm/fby35.c
13
19
14
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
20
diff --git a/hw/misc/i2c-echo.c b/hw/misc/i2c-echo.c
15
new file mode 100644
21
new file mode 100644
16
index XXXXXXX..XXXXXXX
22
index XXXXXXX..XXXXXXX
17
--- /dev/null
23
--- /dev/null
18
+++ b/hw/arm/fby35.c
24
+++ b/hw/misc/i2c-echo.c
19
@@ -XXX,XX +XXX,XX @@
25
@@ -XXX,XX +XXX,XX @@
20
+/*
26
+#include "qemu/osdep.h"
21
+ * Copyright (c) Meta Platforms, Inc. and affiliates. (http://www.meta.com)
27
+#include "qemu/timer.h"
22
+ *
28
+#include "qemu/main-loop.h"
23
+ * This code is licensed under the GPL version 2 or later. See the COPYING
29
+#include "block/aio.h"
24
+ * file in the top-level directory.
30
+#include "hw/i2c/i2c.h"
25
+ */
26
+
31
+
27
+#include "qemu/osdep.h"
32
+#define TYPE_I2C_ECHO "i2c-echo"
28
+#include "hw/boards.h"
33
+OBJECT_DECLARE_SIMPLE_TYPE(I2CEchoState, I2C_ECHO)
29
+
34
+
30
+#define TYPE_FBY35 MACHINE_TYPE_NAME("fby35")
35
+enum i2c_echo_state {
31
+OBJECT_DECLARE_SIMPLE_TYPE(Fby35State, FBY35);
36
+ I2C_ECHO_STATE_IDLE,
32
+
37
+ I2C_ECHO_STATE_START_SEND,
33
+struct Fby35State {
38
+ I2C_ECHO_STATE_ACK,
34
+ MachineState parent_obj;
35
+};
39
+};
36
+
40
+
37
+static void fby35_init(MachineState *machine)
41
+typedef struct I2CEchoState {
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)
38
+{
54
+{
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;
39
+}
88
+}
40
+
89
+
41
+static void fby35_class_init(ObjectClass *oc, void *data)
90
+static int i2c_echo_event(I2CSlave *s, enum i2c_event event)
42
+{
91
+{
43
+ MachineClass *mc = MACHINE_CLASS(oc);
92
+ I2CEchoState *state = I2C_ECHO(s);
44
+
93
+
45
+ mc->desc = "Meta Platforms fby35";
94
+ switch (event) {
46
+ mc->init = fby35_init;
95
+ case I2C_START_RECV:
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;
47
+}
120
+}
48
+
121
+
49
+static const TypeInfo fby35_types[] = {
122
+static uint8_t i2c_echo_recv(I2CSlave *s)
50
+ {
123
+{
51
+ .name = MACHINE_TYPE_NAME("fby35"),
124
+ I2CEchoState *state = I2C_ECHO(s);
52
+ .parent = TYPE_MACHINE,
125
+
53
+ .class_init = fby35_class_init,
126
+ if (state->pos > 2) {
54
+ .instance_size = sizeof(Fby35State),
127
+ return 0xff;
55
+ },
128
+ }
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,
56
+};
174
+};
57
+
175
+
58
+DEFINE_TYPES(fby35_types);
176
+static void register_types(void)
59
diff --git a/MAINTAINERS b/MAINTAINERS
177
+{
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
60
index XXXXXXX..XXXXXXX 100644
183
index XXXXXXX..XXXXXXX 100644
61
--- a/MAINTAINERS
184
--- a/hw/misc/meson.build
62
+++ b/MAINTAINERS
185
+++ b/hw/misc/meson.build
63
@@ -XXX,XX +XXX,XX @@ F: hw/net/ftgmac100.c
186
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('nrf51_rng.c'))
64
F: include/hw/net/ftgmac100.h
187
65
F: docs/system/arm/aspeed.rst
188
softmmu_ss.add(when: 'CONFIG_GRLIB', if_true: files('grlib_ahb_apb_pnp.c'))
66
F: tests/qtest/*aspeed*
189
67
+F: hw/arm/fby35.c
190
+softmmu_ss.add(when: 'CONFIG_I2C', if_true: files('i2c-echo.c'))
68
191
+
69
NRF51
192
specific_ss.add(when: 'CONFIG_AVR_POWER', if_true: files('avr_power.c'))
70
M: Joel Stanley <joel@jms.id.au>
193
71
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
194
specific_ss.add(when: 'CONFIG_MAC_VIA', if_true: files('mac_via.c'))
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'))
85
--
195
--
86
2.35.3
196
2.39.2
87
197
88
198
diff view generated by jsdifflib
1
The Aspeed SDK kernel usually includes support for the lastest HW
1
The Aspeed 2600 I2C controller supports a slave mode which can be
2
features. This is interesting to exercise QEMU and discover the gaps
2
tested with the I2C echo device. Test extracted from :
3
in the models.
4
3
5
Add extra I2C tests for the AST2600 EVB machine to check the new
4
https://lists.nongnu.org/archive/html/qemu-devel/2022-06/msg00183.html
6
register interface.
7
5
8
Message-Id: <20220707091239.1029561-1-clg@kaod.org>
6
Suggested-by: Klaus Jensen <k.jensen@samsung.com>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
---
9
---
11
tests/avocado/machine_aspeed.py | 68 +++++++++++++++++++++++++++++++++
10
tests/avocado/machine_aspeed.py | 10 ++++++++++
12
1 file changed, 68 insertions(+)
11
1 file changed, 10 insertions(+)
13
12
14
diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py
13
diff --git a/tests/avocado/machine_aspeed.py b/tests/avocado/machine_aspeed.py
15
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/avocado/machine_aspeed.py
15
--- a/tests/avocado/machine_aspeed.py
17
+++ b/tests/avocado/machine_aspeed.py
16
+++ b/tests/avocado/machine_aspeed.py
18
@@ -XXX,XX +XXX,XX @@ def test_arm_ast2600_evb_builroot(self):
17
@@ -XXX,XX +XXX,XX @@ def test_arm_ast2600_evb_buildroot(self):
18
'tmp105,bus=aspeed.i2c.bus.3,address=0x4d,id=tmp-test');
19
self.vm.add_args('-device',
20
'ds1338,bus=aspeed.i2c.bus.3,address=0x32');
21
+ self.vm.add_args('-device',
22
+ 'i2c-echo,bus=aspeed.i2c.bus.3,address=0x42');
23
self.do_test_arm_aspeed_buildroot_start(image_path, '0xf00')
24
25
exec_command_and_wait_for_pattern(self,
26
@@ -XXX,XX +XXX,XX @@ def test_arm_ast2600_evb_buildroot(self):
27
year = time.strftime("%Y")
19
exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
28
exec_command_and_wait_for_pattern(self, 'hwclock -f /dev/rtc1', year);
20
29
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
+
65
+ self.vm.add_args('-device',
66
+ 'tmp105,bus=aspeed.i2c.bus.5,address=0x4d,id=tmp-test');
67
+ self.vm.add_args('-device',
68
+ 'ds1338,bus=aspeed.i2c.bus.5,address=0x32');
69
+ self.do_test_arm_aspeed_sdk_start(
70
+ self.workdir + '/ast2600-default/image-bmc', '0xf00')
71
+ self.wait_for_console_pattern('ast2600-default login:')
72
+ exec_command_and_wait_for_pattern(self, 'root', 'Password:')
73
+ exec_command_and_wait_for_pattern(self, '0penBmc', 'root@ast2600-default:~#')
74
+
75
+ exec_command_and_wait_for_pattern(self,
30
+ exec_command_and_wait_for_pattern(self,
76
+ 'echo lm75 0x4d > /sys/class/i2c-dev/i2c-5/device/new_device',
31
+ 'echo slave-24c02 0x1064 > /sys/bus/i2c/devices/i2c-3/new_device',
77
+ 'i2c i2c-5: new_device: Instantiated device lm75 at 0x4d');
32
+ 'i2c i2c-3: new_device: Instantiated device slave-24c02 at 0x64');
33
+ exec_command(self, 'i2cset -y 3 0x42 0x64 0x00 0xaa i');
34
+ time.sleep(0.1)
78
+ exec_command_and_wait_for_pattern(self,
35
+ exec_command_and_wait_for_pattern(self,
79
+ 'cat /sys/class/hwmon/hwmon19/temp1_input', '0')
36
+ 'hexdump /sys/bus/i2c/devices/3-1064/slave-eeprom',
80
+ self.vm.command('qom-set', path='/machine/peripheral/tmp-test',
37
+ '0000000 ffaa ffff ffff ffff ffff ffff ffff ffff');
81
+ property='temperature', value=18000);
38
self.do_test_arm_aspeed_buildroot_poweroff()
82
+ exec_command_and_wait_for_pattern(self,
39
83
+ 'cat /sys/class/hwmon/hwmon19/temp1_input', '18000')
40
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);
90
--
41
--
91
2.35.3
42
2.39.2
92
43
93
44
diff view generated by jsdifflib
1
Some more controllers have been modeled recently. Reflect that in the
1
From: Karthikeyan Pasupathi <pkarthikeyan1509@gmail.com>
2
list of supported devices. New machines were also added.
3
2
4
Signed-off-by: Cédric Le Goater <clg@kaod.org>
3
This patch support Yosemitev2 in QEMU environment.
5
Reviewed-by: Peter Delevoryas <peter@pjd.dev>
4
and introduced EEPROM BMC FRU data support "add fbyv2_bmc_fruid data"
6
Reviewed-by: Joel Stanley <joel@jms.id.au>
5
along with the machine support.
7
Message-Id: <20220706172131.809255-1-clg@kaod.org>
6
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>
8
Signed-off-by: Cédric Le Goater <clg@kaod.org>
12
Signed-off-by: Cédric Le Goater <clg@kaod.org>
9
---
13
---
10
docs/system/arm/aspeed.rst | 14 ++++++++++----
14
docs/system/arm/aspeed.rst | 1 +
11
1 file changed, 10 insertions(+), 4 deletions(-)
15
hw/arm/aspeed_eeprom.h | 3 +++
16
hw/arm/aspeed.c | 31 +++++++++++++++++++++++++++++++
17
hw/arm/aspeed_eeprom.c | 23 +++++++++++++++++++++++
18
4 files changed, 58 insertions(+)
12
19
13
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
20
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
14
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
15
--- a/docs/system/arm/aspeed.rst
22
--- a/docs/system/arm/aspeed.rst
16
+++ b/docs/system/arm/aspeed.rst
23
+++ b/docs/system/arm/aspeed.rst
17
@@ -XXX,XX +XXX,XX @@ AST2600 SoC based machines :
24
@@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines :
18
- ``tacoma-bmc`` OpenPOWER Witherspoon POWER9 AST2600 BMC
25
- ``sonorapass-bmc`` OCP SonoraPass BMC
19
- ``rainier-bmc`` IBM Rainier POWER10 BMC
26
- ``fp5280g2-bmc`` Inspur FP5280G2 BMC
20
- ``fuji-bmc`` Facebook Fuji BMC
27
- ``g220a-bmc`` Bytedance G220A BMC
21
+- ``bletchley-bmc`` Facebook Bletchley BMC
28
+- ``yosemitev2-bmc`` Facebook YosemiteV2 BMC
22
- ``fby35-bmc`` Facebook fby35 BMC
29
23
+- ``qcom-dc-scm-v1-bmc`` Qualcomm DC-SCM V1 BMC
30
AST2600 SoC based machines :
24
+- ``qcom-firework-bmc`` Qualcomm Firework BMC
31
25
32
diff --git a/hw/arm/aspeed_eeprom.h b/hw/arm/aspeed_eeprom.h
26
Supported devices
33
index XXXXXXX..XXXXXXX 100644
27
-----------------
34
--- a/hw/arm/aspeed_eeprom.h
28
@@ -XXX,XX +XXX,XX @@ Supported devices
35
+++ b/hw/arm/aspeed_eeprom.h
29
* Interrupt Controller (VIC)
36
@@ -XXX,XX +XXX,XX @@ extern const size_t fby35_nic_fruid_len;
30
* Timer Controller
37
extern const size_t fby35_bb_fruid_len;
31
* RTC Controller
38
extern const size_t fby35_bmc_fruid_len;
32
- * I2C Controller
39
33
+ * I2C Controller, including the new register interface of the AST2600
40
+extern const uint8_t yosemitev2_bmc_fruid[];
34
* System Control Unit (SCU)
41
+extern const size_t yosemitev2_bmc_fruid_len;
35
* SRAM mapping
42
+
36
* X-DMA Controller (basic interface)
43
#endif
37
@@ -XXX,XX +XXX,XX @@ Supported devices
44
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
38
* LPC Peripheral Controller (a subset of subdevices are supported)
45
index XXXXXXX..XXXXXXX 100644
39
* Hash/Crypto Engine (HACE) - Hash support only. TODO: HMAC and RSA
46
--- a/hw/arm/aspeed.c
40
* ADC
47
+++ b/hw/arm/aspeed.c
41
+ * Secure Boot Controller (AST2600)
48
@@ -XXX,XX +XXX,XX @@ static void ast2600_evb_i2c_init(AspeedMachineState *bmc)
42
+ * eMMC Boot Controller (dummy)
49
TYPE_TMP105, 0x4d);
43
+ * PECI Controller (minimal)
50
}
44
+ * I3C Controller
51
45
52
+static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc)
46
53
+{
47
Missing devices
54
+ AspeedSoCState *soc = &bmc->soc;
48
@@ -XXX,XX +XXX,XX @@ Missing devices
55
+
49
* Super I/O Controller
56
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x51, 128 * KiB);
50
* PCI-Express 1 Controller
57
+ at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * KiB,
51
* Graphic Display Controller
58
+ yosemitev2_bmc_fruid, yosemitev2_bmc_fruid_len);
52
- * PECI Controller
59
+}
53
* MCTP Controller
60
+
54
* Mailbox Controller
61
static void romulus_bmc_i2c_init(AspeedMachineState *bmc)
55
* Virtual UART
62
{
56
* eSPI Controller
63
AspeedSoCState *soc = &bmc->soc;
57
- * I3C Controller
64
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2500_evb_class_init(ObjectClass *oc, void *data)
58
65
aspeed_soc_num_cpus(amc->soc_name);
59
Boot options
66
};
60
------------
67
61
@@ -XXX,XX +XXX,XX @@ Supported devices
68
+static void aspeed_machine_yosemitev2_class_init(ObjectClass *oc, void *data)
62
* LPC Peripheral Controller (a subset of subdevices are supported)
69
+{
63
* Hash/Crypto Engine (HACE) - Hash support only. TODO: HMAC and RSA
70
+ MachineClass *mc = MACHINE_CLASS(oc);
64
* ADC
71
+ AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
65
+ * Secure Boot Controller
72
+
66
+ * PECI Controller (minimal)
73
+ mc->desc = "Facebook YosemiteV2 BMC (ARM1176)";
67
74
+ amc->soc_name = "ast2500-a1";
68
75
+ amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
69
Missing devices
76
+ amc->hw_strap2 = 0;
70
@@ -XXX,XX +XXX,XX @@ Missing devices
77
+ amc->fmc_model = "n25q256a";
71
78
+ amc->spi_model = "mx25l25635e";
72
* PWM and Fan Controller
79
+ amc->num_cs = 2;
73
* Slave GPIO Controller
80
+ amc->i2c_init = yosemitev2_bmc_i2c_init;
74
- * PECI Controller
81
+ mc->default_ram_size = 512 * MiB;
75
* Mailbox Controller
82
+ mc->default_cpus = mc->min_cpus = mc->max_cpus =
76
* Virtual UART
83
+ aspeed_soc_num_cpus(amc->soc_name);
77
* eSPI Controller
84
+};
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);
78
--
134
--
79
2.35.3
135
2.39.2
80
136
81
137
diff view generated by jsdifflib
1
From: Peter Delevoryas <peter@pjd.dev>
1
From: Karthikeyan Pasupathi <pkarthikeyan1509@gmail.com>
2
2
3
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
3
This patch support Tiogapass in QEMU environment.
4
Reviewed-by: Joel Stanley <joel@jms.id.au>
4
and introduced EEPROM BMC FRU data support "add tiogapass_bmc_fruid data"
5
along with the machine support.
6
7
Signed-off-by: Karthikeyan Pasupathi <pkarthikeyan1509@gmail.com>
5
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Reviewed-by: Cédric Le Goater <clg@kaod.org>
6
[ clg: - fixed URL links
9
[ clg: - commit log topic update
7
- Moved Facebook Yosemite section at the end of the file ]
10
- checkpatch issues
8
Message-Id: <20220705191400.41632-10-peter@pjd.dev>
11
- Documentation update ]
12
Message-Id: <20230216184342.253868-1-pkarthikeyan1509@gmail.com>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
---
14
---
11
docs/system/arm/aspeed.rst | 48 ++++++++++++++++++++++++++++++++++++++
15
docs/system/arm/aspeed.rst | 1 +
12
1 file changed, 48 insertions(+)
16
hw/arm/aspeed_eeprom.h | 3 +++
17
hw/arm/aspeed.c | 32 ++++++++++++++++++++++++++++++++
18
hw/arm/aspeed_eeprom.c | 22 ++++++++++++++++++++++
19
4 files changed, 58 insertions(+)
13
20
14
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
21
diff --git a/docs/system/arm/aspeed.rst b/docs/system/arm/aspeed.rst
15
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
16
--- a/docs/system/arm/aspeed.rst
23
--- a/docs/system/arm/aspeed.rst
17
+++ b/docs/system/arm/aspeed.rst
24
+++ b/docs/system/arm/aspeed.rst
18
@@ -XXX,XX +XXX,XX @@ To boot a kernel directly from a Zephyr build tree:
25
@@ -XXX,XX +XXX,XX @@ AST2500 SoC based machines :
19
26
- ``fp5280g2-bmc`` Inspur FP5280G2 BMC
20
$ qemu-system-arm -M ast1030-evb -nographic \
27
- ``g220a-bmc`` Bytedance G220A BMC
21
-kernel zephyr.elf
28
- ``yosemitev2-bmc`` Facebook YosemiteV2 BMC
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;
22
+
43
+
23
+Facebook Yosemite v3.5 Platform and CraterLake Server (``fby35``)
44
extern const uint8_t fby35_nic_fruid[];
24
+==================================================================
45
extern const uint8_t fby35_bb_fruid[];
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;
25
+
58
+
26
+Facebook has a series of multi-node compute server designs named
59
+ at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x54, 128 * KiB);
27
+Yosemite. The most recent version released was
60
+ at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * KiB,
28
+`Yosemite v3 <https://www.opencompute.org/documents/ocp-yosemite-v3-platform-design-specification-1v16-pdf>`__.
61
+ tiogapass_bmc_fruid, tiogapass_bmc_fruid_len);
62
+}
29
+
63
+
30
+Yosemite v3.5 is an iteration on this design, and is very similar: there's a
64
static void create_pca9552(AspeedSoCState *soc, int bus_id, int addr)
31
+baseboard with a BMC, and 4 server slots. The new server board design termed
65
{
32
+"CraterLake" includes a Bridge IC (BIC), with room for expansion boards to
66
i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, bus_id),
33
+include various compute accelerators (video, inferencing, etc). At the moment,
67
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_romulus_class_init(ObjectClass *oc, void *data)
34
+only the first server slot's BIC is included.
68
aspeed_soc_num_cpus(amc->soc_name);
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);
35
+
75
+
36
+Yosemite v3.5 is itself a sled which fits into a 40U chassis, and 3 sleds
76
+ mc->desc = "Facebook Tiogapass BMC (ARM1176)";
37
+can be fit into a chassis. See `here <https://www.opencompute.org/products/423/wiwynn-yosemite-v3-server>`__
77
+ amc->soc_name = "ast2500-a1";
38
+for an example.
78
+ amc->hw_strap1 = AST2500_EVB_HW_STRAP1;
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
+};
39
+
89
+
40
+In this generation, the BMC is an AST2600 and each BIC is an AST1030. The BMC
90
static void aspeed_machine_sonorapass_class_init(ObjectClass *oc, void *data)
41
+runs `OpenBMC <https://github.com/facebook/openbmc>`__, and the BIC runs
91
{
42
+`OpenBIC <https://github.com/facebook/openbic>`__.
92
MachineClass *mc = MACHINE_CLASS(oc);
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
+};
43
+
132
+
44
+Firmware images can be retrieved from the Github releases or built from the
133
const uint8_t fby35_nic_fruid[] = {
45
+source code, see the README's for instructions on that. This image uses the
134
0x01, 0x00, 0x00, 0x01, 0x0f, 0x20, 0x00, 0xcf, 0x01, 0x0e, 0x19, 0xd7,
46
+"fby35" machine recipe from OpenBMC, and the "yv35-cl" target from OpenBIC.
135
0x5e, 0xcf, 0xc8, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0x58, 0xdd,
47
+Some reference images can also be found here:
136
@@ -XXX,XX +XXX,XX @@ const uint8_t yosemitev2_bmc_fruid[] = {
48
+
137
0x6e, 0x66, 0x69, 0x67, 0x20, 0x41, 0xc1, 0x45,
49
+.. code-block:: bash
138
};
50
+
139
51
+ $ wget https://github.com/facebook/openbmc/releases/download/openbmc-e2294ff5d31d/fby35.mtd
140
+const size_t tiogapass_bmc_fruid_len = sizeof(tiogapass_bmc_fruid);
52
+ $ wget https://github.com/peterdelevoryas/OpenBIC/releases/download/oby35-cl-2022.13.01/Y35BCL.elf
141
const size_t fby35_nic_fruid_len = sizeof(fby35_nic_fruid);
53
+
142
const size_t fby35_bb_fruid_len = sizeof(fby35_bb_fruid);
54
+Since this machine has multiple SoC's, each with their own serial console, the
143
const size_t fby35_bmc_fruid_len = sizeof(fby35_bmc_fruid);
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.
70
--
144
--
71
2.35.3
145
2.39.2
72
146
73
147
diff view generated by jsdifflib
1
The BMC boots from the first flash device by fetching instructions
1
From: Sittisak Sinprem <ssinprem@celestica.com>
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.
6
2
7
See commit 1a15311a12fa ("hw/arm/aspeed: add a 'execute-in-place'
3
Signed-off-by: Sittisak Sinprem <ssinprem@celestica.com>
8
property to boot directly from CE0")
4
Reviewed-by: Peter Delevoryas <peter@pjd.dev>
9
5
[ clg: checkpatch issues ]
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
6
Message-Id: <167660539263.10409.9736070122710923479-1@git.sr.ht>
11
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
12
Message-Id: <20220705191400.41632-8-peter@pjd.dev>
13
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
Signed-off-by: Cédric Le Goater <clg@kaod.org>
14
---
8
---
15
hw/arm/fby35.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++
9
hw/nvram/eeprom_at24c.c | 30 +++++++++++++++++++++++++++---
16
1 file changed, 83 insertions(+)
10
1 file changed, 27 insertions(+), 3 deletions(-)
17
11
18
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
12
diff --git a/hw/nvram/eeprom_at24c.c b/hw/nvram/eeprom_at24c.c
19
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/arm/fby35.c
14
--- a/hw/nvram/eeprom_at24c.c
21
+++ b/hw/arm/fby35.c
15
+++ b/hw/nvram/eeprom_at24c.c
22
@@ -XXX,XX +XXX,XX @@
16
@@ -XXX,XX +XXX,XX @@ struct EEPROMState {
23
#include "qemu/units.h"
17
uint16_t cur;
24
#include "qapi/error.h"
18
/* total size in bytes */
25
#include "sysemu/sysemu.h"
19
uint32_t rsize;
26
+#include "sysemu/block-backend.h"
20
+ /*
27
#include "hw/boards.h"
21
+ * address byte number
28
#include "hw/arm/aspeed_soc.h"
22
+ * for 24c01, 24c02 size <= 256 byte, use only 1 byte
29
23
+ * otherwise size > 256, use 2 byte
30
@@ -XXX,XX +XXX,XX @@ struct Fby35State {
24
+ */
31
MemoryRegion bmc_boot_rom;
25
+ uint8_t asize;
32
33
AspeedSoCState bmc;
34
+
26
+
35
+ bool mmio_exec;
27
bool writable;
36
};
28
/* cells changed since last START? */
37
29
bool changed;
38
#define FBY35_BMC_RAM_SIZE (2 * GiB)
30
@@ -XXX,XX +XXX,XX @@ uint8_t at24c_eeprom_recv(I2CSlave *s)
39
+#define FBY35_BMC_FIRMWARE_ADDR 0x0
31
EEPROMState *ee = AT24C_EE(s);
40
+
32
uint8_t ret;
41
+static void fby35_bmc_write_boot_rom(DriveInfo *dinfo, MemoryRegion *mr,
33
42
+ hwaddr offset, size_t rom_size,
34
- if (ee->haveaddr == 1) {
43
+ Error **errp)
35
+ /*
44
+{
36
+ * If got the byte address but not completely with address size
45
+ BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
37
+ * will return the invalid value
46
+ g_autofree void *storage = NULL;
38
+ */
47
+ int64_t size;
39
+ if (ee->haveaddr > 0 && ee->haveaddr < ee->asize) {
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
}
48
+
61
+
49
+ /*
62
+ /*
50
+ * The block backend size should have already been 'validated' by
63
+ * If address size didn't define with property set
51
+ * the creation of the m25p80 object.
64
+ * value is 0 as default, setting it by Rom size detecting.
52
+ */
65
+ */
53
+ size = blk_getlength(blk);
66
+ if (ee->asize == 0) {
54
+ if (size <= 0) {
67
+ if (ee->rsize <= 256) {
55
+ error_setg(errp, "failed to get flash size");
68
+ ee->asize = 1;
56
+ return;
57
+ }
58
+
59
+ if (rom_size > size) {
60
+ rom_size = size;
61
+ }
62
+
63
+ storage = g_malloc0(rom_size);
64
+ if (blk_pread(blk, 0, storage, rom_size) < 0) {
65
+ error_setg(errp, "failed to read the initial flash content");
66
+ return;
67
+ }
68
+
69
+ /* TODO: find a better way to install the ROM */
70
+ memcpy(memory_region_get_ram_ptr(mr) + offset, storage, rom_size);
71
+}
72
73
static void fby35_bmc_init(Fby35State *s)
74
{
75
+ DriveInfo *drive0 = drive_get(IF_MTD, 0, 0);
76
+
77
memory_region_init(&s->bmc_memory, OBJECT(s), "bmc-memory", UINT64_MAX);
78
memory_region_init_ram(&s->bmc_dram, OBJECT(s), "bmc-dram",
79
FBY35_BMC_RAM_SIZE, &error_abort);
80
@@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s)
81
qdev_realize(DEVICE(&s->bmc), NULL, &error_abort);
82
83
aspeed_board_init_flashes(&s->bmc.fmc, "n25q00", 2, 0);
84
+
85
+ /* Install first FMC flash content as a boot rom. */
86
+ if (drive0) {
87
+ AspeedSMCFlash *fl = &s->bmc.fmc.flashes[0];
88
+ MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
89
+ uint64_t size = memory_region_size(&fl->mmio);
90
+
91
+ if (s->mmio_exec) {
92
+ memory_region_init_alias(boot_rom, NULL, "aspeed.boot_rom",
93
+ &fl->mmio, 0, size);
94
+ memory_region_add_subregion(&s->bmc_memory, FBY35_BMC_FIRMWARE_ADDR,
95
+ boot_rom);
96
+ } else {
69
+ } else {
97
+
70
+ ee->asize = 2;
98
+ memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom",
99
+ size, &error_abort);
100
+ memory_region_add_subregion(&s->bmc_memory, FBY35_BMC_FIRMWARE_ADDR,
101
+ boot_rom);
102
+ fby35_bmc_write_boot_rom(drive0, boot_rom, FBY35_BMC_FIRMWARE_ADDR,
103
+ size, &error_abort);
104
+ }
71
+ }
105
+ }
72
+ }
106
}
73
}
107
74
108
static void fby35_init(MachineState *machine)
75
static
109
@@ -XXX,XX +XXX,XX @@ static void fby35_init(MachineState *machine)
76
@@ -XXX,XX +XXX,XX @@ void at24c_eeprom_reset(DeviceState *state)
110
fby35_bmc_init(s);
77
111
}
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
+static bool fby35_get_mmio_exec(Object *obj, Error **errp)
81
DEFINE_PROP_BOOL("writable", EEPROMState, writable, true),
115
+{
82
DEFINE_PROP_DRIVE("drive", EEPROMState, blk),
116
+ return FBY35(obj)->mmio_exec;
83
DEFINE_PROP_END_OF_LIST()
117
+}
118
+
119
+static void fby35_set_mmio_exec(Object *obj, bool value, Error **errp)
120
+{
121
+ FBY35(obj)->mmio_exec = value;
122
+}
123
+
124
+static void fby35_instance_init(Object *obj)
125
+{
126
+ FBY35(obj)->mmio_exec = false;
127
+}
128
+
129
static void fby35_class_init(ObjectClass *oc, void *data)
130
{
131
MachineClass *mc = MACHINE_CLASS(oc);
132
@@ -XXX,XX +XXX,XX @@ static void fby35_class_init(ObjectClass *oc, void *data)
133
mc->no_floppy = 1;
134
mc->no_cdrom = 1;
135
mc->min_cpus = mc->max_cpus = mc->default_cpus = 2;
136
+
137
+ object_class_property_add_bool(oc, "execute-in-place",
138
+ fby35_get_mmio_exec,
139
+ fby35_set_mmio_exec);
140
+ object_class_property_set_description(oc, "execute-in-place",
141
+ "boot directly from CE0 flash device");
142
}
143
144
static const TypeInfo fby35_types[] = {
145
@@ -XXX,XX +XXX,XX @@ static const TypeInfo fby35_types[] = {
146
.parent = TYPE_MACHINE,
147
.class_init = fby35_class_init,
148
.instance_size = sizeof(Fby35State),
149
+ .instance_init = fby35_instance_init,
150
},
151
};
152
153
--
84
--
154
2.35.3
85
2.39.2
155
86
156
87
diff view generated by jsdifflib
1
From: Peter Delevoryas <peter@pjd.dev>
1
From: Sittisak Sinprem <ssinprem@celestica.com>
2
2
3
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
3
Device 24C64 the size is 64 kilobits = 8kilobyte
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
4
Device 24C02 the size is 2 kilobits = 256byte
5
Message-Id: <20220712023219.41065-4-peter@pjd.dev>
5
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>
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
---
11
---
8
hw/arm/aspeed.c | 14 +++++++++++++-
12
hw/arm/aspeed.c | 36 ++++++++++++++++++++----------------
9
1 file changed, 13 insertions(+), 1 deletion(-)
13
1 file changed, 20 insertions(+), 16 deletions(-)
10
14
11
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
15
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
12
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/aspeed.c
17
--- a/hw/arm/aspeed.c
14
+++ b/hw/arm/aspeed.c
18
+++ b/hw/arm/aspeed.c
15
@@ -XXX,XX +XXX,XX @@ static void fby35_reset(MachineState *state)
19
@@ -XXX,XX +XXX,XX @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc)
16
20
i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4c);
17
qemu_devices_reset();
21
i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4d);
18
22
19
- /* Board ID */
23
- at24c_eeprom_init(i2c[19], 0x52, 64 * KiB);
20
+ /* Board ID: 7 (Class-1, 4 slots) */
24
- at24c_eeprom_init(i2c[20], 0x50, 2 * KiB);
21
object_property_set_bool(OBJECT(gpio), "gpioV4", true, &error_fatal);
25
- at24c_eeprom_init(i2c[22], 0x52, 2 * KiB);
22
object_property_set_bool(OBJECT(gpio), "gpioV5", true, &error_fatal);
26
+ /*
23
object_property_set_bool(OBJECT(gpio), "gpioV6", true, &error_fatal);
27
+ * EEPROM 24c64 size is 64Kbits or 8 Kbytes
24
object_property_set_bool(OBJECT(gpio), "gpioV7", false, &error_fatal);
28
+ * 24c02 size is 2Kbits or 256 bytes
25
+
29
+ */
26
+ /* Slot presence pins, inverse polarity. (False means present) */
30
+ at24c_eeprom_init(i2c[19], 0x52, 8 * KiB);
27
+ object_property_set_bool(OBJECT(gpio), "gpioH4", false, &error_fatal);
31
+ at24c_eeprom_init(i2c[20], 0x50, 256);
28
+ object_property_set_bool(OBJECT(gpio), "gpioH5", true, &error_fatal);
32
+ at24c_eeprom_init(i2c[22], 0x52, 256);
29
+ object_property_set_bool(OBJECT(gpio), "gpioH6", true, &error_fatal);
33
30
+ object_property_set_bool(OBJECT(gpio), "gpioH7", true, &error_fatal);
34
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x48);
31
+
35
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x49);
32
+ /* Slot 12v power pins, normal polarity. (True means powered-on) */
36
i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x4a);
33
+ object_property_set_bool(OBJECT(gpio), "gpioB2", true, &error_fatal);
37
i2c_slave_create_simple(i2c[3], TYPE_TMP422, 0x4c);
34
+ object_property_set_bool(OBJECT(gpio), "gpioB3", false, &error_fatal);
38
35
+ object_property_set_bool(OBJECT(gpio), "gpioB4", false, &error_fatal);
39
- at24c_eeprom_init(i2c[8], 0x51, 64 * KiB);
36
+ object_property_set_bool(OBJECT(gpio), "gpioB5", false, &error_fatal);
40
+ at24c_eeprom_init(i2c[8], 0x51, 8 * KiB);
37
}
41
i2c_slave_create_simple(i2c[8], TYPE_LM75, 0x4a);
38
42
39
static void aspeed_machine_fby35_class_init(ObjectClass *oc, void *data)
43
i2c_slave_create_simple(i2c[50], TYPE_LM75, 0x4c);
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);
40
--
82
--
41
2.35.3
83
2.39.2
42
84
43
85
diff view generated by jsdifflib
1
From: Peter Delevoryas <peter@pjd.dev>
1
The default boot address of the Aspeed SoCs is 0x0. For this reason,
2
the FMC flash device contents are remapped by HW on the first 256MB of
3
the address space. In QEMU, this is currently done in the machine init
4
with the setup of a region alias.
2
5
3
This change moves the code that connects the SoC UART's to serial_hd's
6
Move this code to the SoC and introduce an extra container to prepare
4
to the machine.
7
ground for the boot ROM region which will overlap the FMC flash
8
remapping.
5
9
6
It makes each UART a proper child member of the SoC, and then allows the
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
machine to selectively initialize the chardev for each UART with a
8
serial_hd.
9
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>
52
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
53
---
12
---
54
include/hw/arm/aspeed_soc.h | 7 ++++--
13
include/hw/arm/aspeed_soc.h | 5 +++++
55
hw/arm/aspeed.c | 22 +++++++++++++---
14
hw/arm/aspeed.c | 13 +------------
56
hw/arm/aspeed_ast10x0.c | 8 +++++-
15
hw/arm/aspeed_ast2600.c | 13 +++++++++++++
57
hw/arm/aspeed_ast2600.c | 8 +++++-
16
hw/arm/aspeed_soc.c | 14 ++++++++++++++
58
hw/arm/aspeed_soc.c | 50 +++++++++++++++++++++++++------------
17
hw/arm/fby35.c | 8 +-------
59
5 files changed, 71 insertions(+), 24 deletions(-)
18
5 files changed, 34 insertions(+), 19 deletions(-)
60
19
61
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
20
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
62
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
63
--- a/include/hw/arm/aspeed_soc.h
22
--- a/include/hw/arm/aspeed_soc.h
64
+++ b/include/hw/arm/aspeed_soc.h
23
+++ 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 >*/
80
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
24
@@ -XXX,XX +XXX,XX @@ struct AspeedSoCState {
81
AspeedSDHCIState emmc;
25
MemoryRegion *dram_mr;
82
AspeedLPCState lpc;
26
MemoryRegion dram_container;
83
AspeedPECIState peci;
27
MemoryRegion sram;
84
- uint32_t uart_default;
28
+ MemoryRegion spi_boot_container;
85
+ SerialMM uart[ASPEED_UARTS_NUM];
29
+ MemoryRegion spi_boot;
86
Clock *sysclk;
30
AspeedVICState vic;
87
UnimplementedDeviceState iomem;
31
AspeedRtcState rtc;
88
UnimplementedDeviceState video;
32
AspeedTimerCtrlState timerctrl;
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,
89
@@ -XXX,XX +XXX,XX @@ enum {
41
@@ -XXX,XX +XXX,XX @@ enum {
42
ASPEED_DEV_JTAG1,
90
};
43
};
91
44
45
+#define ASPEED_SOC_SPI_BOOT_ADDR 0x0
46
+
92
qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev);
47
qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev);
93
-void aspeed_soc_uart_init(AspeedSoCState *s);
48
bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp);
94
+bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp);
49
void aspeed_soc_uart_set_chr(AspeedSoCState *s, int dev, Chardev *chr);
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,
99
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
50
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
100
index XXXXXXX..XXXXXXX 100644
51
index XXXXXXX..XXXXXXX 100644
101
--- a/hw/arm/aspeed.c
52
--- a/hw/arm/aspeed.c
102
+++ b/hw/arm/aspeed.c
53
+++ 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);
133
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
54
@@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine)
134
object_property_set_int(OBJECT(&bmc->soc), "hw-prot-key",
55
MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
135
ASPEED_SCU_PROT_KEY, &error_abort);
56
uint64_t size = memory_region_size(&fl->mmio);
136
}
57
137
- qdev_prop_set_uint32(DEVICE(&bmc->soc), "uart-default",
58
- /*
138
- amc->uart_default);
59
- * create a ROM region using the default mapping window size of
139
+ connect_serial_hds_to_uarts(bmc);
60
- * the flash module. The window size is 64MB for the AST2400
140
qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
61
- * SoC and 128MB for the AST2500 SoC, which is twice as big as
141
62
- * needed by the flash modules of the Aspeed machines.
142
aspeed_board_init_flashes(&bmc->soc.fmc,
63
- */
143
@@ -XXX,XX +XXX,XX @@ static void aspeed_minibmc_machine_init(MachineState *machine)
64
- if (ASPEED_MACHINE(machine)->mmio_exec) {
144
65
- memory_region_init_alias(boot_rom, NULL, "aspeed.boot_rom",
145
object_property_set_link(OBJECT(&bmc->soc), "memory",
66
- &fl->mmio, 0, size);
146
OBJECT(get_system_memory()), &error_abort);
67
- memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
147
- qdev_prop_set_uint32(DEVICE(&bmc->soc), "uart-default",
68
- boot_rom);
148
- amc->uart_default);
69
- } else {
149
+ connect_serial_hds_to_uarts(bmc);
70
+ if (!ASPEED_MACHINE(machine)->mmio_exec) {
150
qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort);
71
memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom",
151
72
size, &error_abort);
152
aspeed_board_init_flashes(&bmc->soc.fmc,
73
memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR,
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),
179
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
74
diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c
180
index XXXXXXX..XXXXXXX 100644
75
index XXXXXXX..XXXXXXX 100644
181
--- a/hw/arm/aspeed_ast2600.c
76
--- a/hw/arm/aspeed_ast2600.c
182
+++ b/hw/arm/aspeed_ast2600.c
77
+++ b/hw/arm/aspeed_ast2600.c
183
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj)
78
@@ -XXX,XX +XXX,XX @@
184
object_initialize_child(obj, "mii[*]", &s->mii[i], TYPE_ASPEED_MII);
79
#define ASPEED_SOC_DPMCU_SIZE 0x00040000
185
}
80
186
81
static const hwaddr aspeed_soc_ast2600_memmap[] = {
187
+ for (i = 0; i < sc->uarts_num; i++) {
82
+ [ASPEED_DEV_SPI_BOOT] = ASPEED_SOC_SPI_BOOT_ADDR,
188
+ object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_SERIAL_MM);
83
[ASPEED_DEV_SRAM] = 0x10000000,
189
+ }
84
[ASPEED_DEV_DPMCU] = 0x18000000,
85
/* 0x16000000 0x17FFFFFF : AHB BUS do LPC Bus bridge */
86
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
87
qemu_irq irq;
88
g_autofree char *sram_name = NULL;
89
90
+ /* Default boot region (SPI memory or ROMs) */
91
+ memory_region_init(&s->spi_boot_container, OBJECT(s),
92
+ "aspeed.spi_boot_container", 0x10000000);
93
+ memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SPI_BOOT],
94
+ &s->spi_boot_container);
190
+
95
+
191
snprintf(typename, sizeof(typename), TYPE_ASPEED_XDMA "-%s", socname);
96
/* IO space */
192
object_initialize_child(obj, "xdma", &s->xdma, typename);
97
aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io",
193
98
sc->memmap[ASPEED_DEV_IOMEM],
194
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
99
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)
195
aspeed_soc_get_irq(s, ASPEED_DEV_ADC));
100
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
196
101
aspeed_soc_get_irq(s, ASPEED_DEV_FMC));
197
/* UART */
102
198
- aspeed_soc_uart_init(s);
103
+ /* Set up an alias on the FMC CE0 region (boot default) */
199
+ if (!aspeed_soc_uart_realize(s, errp)) {
104
+ MemoryRegion *fmc0_mmio = &s->fmc.flashes[0].mmio;
200
+ return;
105
+ memory_region_init_alias(&s->spi_boot, OBJECT(s), "aspeed.spi_boot",
201
+ }
106
+ fmc0_mmio, 0, memory_region_size(fmc0_mmio));
202
107
+ memory_region_add_subregion(&s->spi_boot_container, 0x0, &s->spi_boot);
203
/* I2C */
108
+
204
object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
109
/* SPI */
110
for (i = 0; i < sc->spis_num; i++) {
111
object_property_set_link(OBJECT(&s->spi[i]), "dram",
205
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
112
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
206
index XXXXXXX..XXXXXXX 100644
113
index XXXXXXX..XXXXXXX 100644
207
--- a/hw/arm/aspeed_soc.c
114
--- a/hw/arm/aspeed_soc.c
208
+++ b/hw/arm/aspeed_soc.c
115
+++ b/hw/arm/aspeed_soc.c
209
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_init(Object *obj)
116
@@ -XXX,XX +XXX,XX @@
210
TYPE_FTGMAC100);
117
#define ASPEED_SOC_IOMEM_SIZE 0x00200000
211
}
118
212
119
static const hwaddr aspeed_soc_ast2400_memmap[] = {
213
+ for (i = 0; i < sc->uarts_num; i++) {
120
+ [ASPEED_DEV_SPI_BOOT] = ASPEED_SOC_SPI_BOOT_ADDR,
214
+ object_initialize_child(obj, "uart[*]", &s->uart[i], TYPE_SERIAL_MM);
121
[ASPEED_DEV_IOMEM] = 0x1E600000,
215
+ }
122
[ASPEED_DEV_FMC] = 0x1E620000,
123
[ASPEED_DEV_SPI1] = 0x1E630000,
124
@@ -XXX,XX +XXX,XX @@ static const hwaddr aspeed_soc_ast2400_memmap[] = {
125
};
126
127
static const hwaddr aspeed_soc_ast2500_memmap[] = {
128
+ [ASPEED_DEV_SPI_BOOT] = ASPEED_SOC_SPI_BOOT_ADDR,
129
[ASPEED_DEV_IOMEM] = 0x1E600000,
130
[ASPEED_DEV_FMC] = 0x1E620000,
131
[ASPEED_DEV_SPI1] = 0x1E630000,
132
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
133
Error *err = NULL;
134
g_autofree char *sram_name = NULL;
135
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);
216
+
141
+
217
snprintf(typename, sizeof(typename), TYPE_ASPEED_XDMA "-%s", socname);
142
/* IO space */
218
object_initialize_child(obj, "xdma", &s->xdma, typename);
143
aspeed_mmio_map_unimplemented(s, SYS_BUS_DEVICE(&s->iomem), "aspeed.io",
219
144
sc->memmap[ASPEED_DEV_IOMEM],
220
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
145
@@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
221
aspeed_soc_get_irq(s, ASPEED_DEV_ADC));
146
sysbus_connect_irq(SYS_BUS_DEVICE(&s->fmc), 0,
222
147
aspeed_soc_get_irq(s, ASPEED_DEV_FMC));
223
/* UART */
148
224
- aspeed_soc_uart_init(s);
149
+ /* Set up an alias on the FMC CE0 region (boot default) */
225
+ if (!aspeed_soc_uart_realize(s, errp)) {
150
+ MemoryRegion *fmc0_mmio = &s->fmc.flashes[0].mmio;
226
+ return;
151
+ memory_region_init_alias(&s->spi_boot, OBJECT(s), "aspeed.spi_boot",
227
+ }
152
+ fmc0_mmio, 0, memory_region_size(fmc0_mmio));
228
153
+ memory_region_add_subregion(&s->spi_boot_container, 0x0, &s->spi_boot);
229
/* I2C */
154
+
230
object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr),
155
/* SPI */
231
@@ -XXX,XX +XXX,XX @@ static Property aspeed_soc_properties[] = {
156
for (i = 0; i < sc->spis_num; i++) {
232
MemoryRegion *),
157
if (!sysbus_realize(SYS_BUS_DEVICE(&s->spi[i]), errp)) {
233
DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
158
diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c
234
MemoryRegion *),
159
index XXXXXXX..XXXXXXX 100644
235
- DEFINE_PROP_UINT32("uart-default", AspeedSoCState, uart_default,
160
--- a/hw/arm/fby35.c
236
- ASPEED_DEV_UART5),
161
+++ b/hw/arm/fby35.c
237
DEFINE_PROP_END_OF_LIST(),
162
@@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s)
238
};
163
MemoryRegion *boot_rom = g_new(MemoryRegion, 1);
239
164
uint64_t size = memory_region_size(&fl->mmio);
240
@@ -XXX,XX +XXX,XX @@ qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev)
165
241
return ASPEED_SOC_GET_CLASS(s)->get_irq(s, dev);
166
- if (s->mmio_exec) {
242
}
167
- memory_region_init_alias(boot_rom, NULL, "aspeed.boot_rom",
243
168
- &fl->mmio, 0, size);
244
-void aspeed_soc_uart_init(AspeedSoCState *s)
169
- memory_region_add_subregion(&s->bmc_memory, FBY35_BMC_FIRMWARE_ADDR,
245
+bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp)
170
- boot_rom);
246
{
171
- } else {
247
AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
248
- int i, uart;
249
-
172
-
250
- /* Attach an 8250 to the IO space as our UART */
173
+ if (!s->mmio_exec) {
251
- serial_mm_init(s->memory, sc->memmap[s->uart_default], 2,
174
memory_region_init_rom(boot_rom, NULL, "aspeed.boot_rom",
252
- aspeed_soc_get_irq(s, s->uart_default), 38400,
175
size, &error_abort);
253
- serial_hd(0), DEVICE_LITTLE_ENDIAN);
176
memory_region_add_subregion(&s->bmc_memory, FBY35_BMC_FIRMWARE_ADDR,
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
/*
291
--
177
--
292
2.35.3
178
2.39.2
293
179
294
180
diff view generated by jsdifflib
1
From: Peter Delevoryas <peter@pjd.dev>
1
To avoid the SPI transactions fetching instructions from the FMC CE0
2
flash device and speed up boot, a ROM can be created if a drive is
3
available.
2
4
3
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
5
Reverse the logic to allow a machine to boot without a drive, using a
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
6
block device instead :
5
Message-Id: <20220705191400.41632-5-peter@pjd.dev>
7
8
-blockdev node-name=fmc0,driver=file,filename=/path/to/flash.img \
9
-device mx66u51235f,bus=ssi.0,drive=fmc0
10
6
Signed-off-by: Cédric Le Goater <clg@kaod.org>
11
Signed-off-by: Cédric Le Goater <clg@kaod.org>
7
---
12
---
8
include/hw/arm/aspeed_soc.h | 2 ++
13
hw/arm/aspeed.c | 47 +++++++++++++++++++++++++++--------------------
9
hw/arm/aspeed.c | 2 +-
14
1 file changed, 27 insertions(+), 20 deletions(-)
10
2 files changed, 3 insertions(+), 1 deletion(-)
11
15
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 */
24
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
16
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
25
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
26
--- a/hw/arm/aspeed.c
18
--- a/hw/arm/aspeed.c
27
+++ b/hw/arm/aspeed.c
19
+++ 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
28
@@ -XXX,XX +XXX,XX @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
34
@@ -XXX,XX +XXX,XX @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size,
29
rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr);
35
rom_add_blob_fixed("aspeed.boot_rom", storage, rom_size, addr);
30
}
36
}
31
37
32
-static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
38
+/*
33
+void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
39
+ * Create a ROM and copy the flash contents at the expected address
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,
34
unsigned int count, int unit0)
55
unsigned int count, int unit0)
35
{
56
{
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);
36
int i;
62
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
37
--
104
--
38
2.35.3
105
2.39.2
39
106
40
107
diff view generated by jsdifflib
Deleted patch
1
From: Peter Delevoryas <peter@pjd.dev>
2
1
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
Deleted patch
1
From: Iris Chen <irischenlj@fb.com>
2
1
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
1
From: Iris Chen <irischenlj@fb.com>
1
It's cleaner and removes the curious '+ 1' required to skip the DMA
2
IRQ line of the controller.
2
3
3
Signed-off-by: Iris Chen <irischenlj@fb.com>
4
Signed-off-by: Cédric Le Goater <clg@kaod.org>
4
Reviewed-by: Cédric Le Goater <clg@kaod.org>
5
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
5
Message-Id: <20220627185234.1911337-3-irischenlj@fb.com>
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
tests/qtest/aspeed_smc-test.c | 111 ++++++++++++++++++++++++++++++++++
8
hw/arm/aspeed.c | 2 +-
9
1 file changed, 111 insertions(+)
9
hw/ssi/aspeed_smc.c | 5 +----
10
2 files changed, 2 insertions(+), 5 deletions(-)
10
11
11
diff --git a/tests/qtest/aspeed_smc-test.c b/tests/qtest/aspeed_smc-test.c
12
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
12
index XXXXXXX..XXXXXXX 100644
13
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qtest/aspeed_smc-test.c
14
--- a/hw/arm/aspeed.c
14
+++ b/tests/qtest/aspeed_smc-test.c
15
+++ b/hw/arm/aspeed.c
15
@@ -XXX,XX +XXX,XX @@ static void read_page_mem(uint32_t addr, uint32_t *page)
16
@@ -XXX,XX +XXX,XX @@ void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype,
17
qdev_realize_and_unref(dev, BUS(s->spi), &error_fatal);
18
19
cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0);
20
- sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line);
21
+ qdev_connect_gpio_out_named(DEVICE(s), "cs", i, cs_line);
16
}
22
}
17
}
23
}
18
24
19
+static void write_page_mem(uint32_t addr, uint32_t write_value)
25
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
20
+{
26
index XXXXXXX..XXXXXXX 100644
21
+ spi_ctrl_setmode(CTRL_WRITEMODE, PP);
27
--- a/hw/ssi/aspeed_smc.c
22
+
28
+++ b/hw/ssi/aspeed_smc.c
23
+ for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
29
@@ -XXX,XX +XXX,XX @@ static void aspeed_smc_realize(DeviceState *dev, Error **errp)
24
+ writel(ASPEED_FLASH_BASE + addr + i * 4, write_value);
30
25
+ }
31
/* Setup cs_lines for peripherals */
26
+}
32
s->cs_lines = g_new0(qemu_irq, asc->cs_num_max);
27
+
33
-
28
+static void assert_page_mem(uint32_t addr, uint32_t expected_value)
34
- for (i = 0; i < asc->cs_num_max; ++i) {
29
+{
35
- sysbus_init_irq(sbd, &s->cs_lines[i]);
30
+ uint32_t page[FLASH_PAGE_SIZE / 4];
36
- }
31
+ read_page_mem(addr, page);
37
+ qdev_init_gpio_out_named(DEVICE(s), s->cs_lines, "cs", asc->cs_num_max);
32
+ for (int i = 0; i < FLASH_PAGE_SIZE / 4; i++) {
38
33
+ g_assert_cmphex(page[i], ==, expected_value);
39
/* The memory region for the controller registers */
34
+ }
40
memory_region_init_io(&s->mmio, OBJECT(s), &aspeed_smc_ops, s,
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
--
41
--
148
2.35.3
42
2.39.2
149
43
150
44
diff view generated by jsdifflib
Deleted patch
1
From: Peter Delevoryas <peter@pjd.dev>
2
1
3
Verify the current behavior, which is that input pins can be modified by
4
guest OS register writes.
5
6
Signed-off-by: Peter Delevoryas <peter@pjd.dev>
7
Reviewed-by: Cédric Le Goater <clg@kaod.org>
8
Message-Id: <20220712023219.41065-2-peter@pjd.dev>
9
Signed-off-by: Cédric Le Goater <clg@kaod.org>
10
---
11
tests/qtest/aspeed_gpio-test.c | 27 +++++++++++++++++++++++++++
12
1 file changed, 27 insertions(+)
13
14
diff --git a/tests/qtest/aspeed_gpio-test.c b/tests/qtest/aspeed_gpio-test.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/tests/qtest/aspeed_gpio-test.c
17
+++ b/tests/qtest/aspeed_gpio-test.c
18
@@ -XXX,XX +XXX,XX @@
19
#include "qapi/qmp/qdict.h"
20
#include "libqtest-single.h"
21
22
+#define AST2600_GPIO_BASE 0x1E780000
23
+
24
+#define GPIO_ABCD_DATA_VALUE 0x000
25
+#define GPIO_ABCD_DIRECTION 0x004
26
+
27
static void test_set_colocated_pins(const void *data)
28
{
29
QTestState *s = (QTestState *)data;
30
@@ -XXX,XX +XXX,XX @@ static void test_set_colocated_pins(const void *data)
31
g_assert(!qtest_qom_get_bool(s, "/machine/soc/gpio", "gpioV7"));
32
}
33
34
+static void test_set_input_pins(const void *data)
35
+{
36
+ QTestState *s = (QTestState *)data;
37
+ char name[16];
38
+ uint32_t value;
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
66
--
67
2.35.3
68
69
diff view generated by jsdifflib