1 | The following changes since commit eae587e8e3694b1aceab23239493fb4c7e1a80f5: | 1 | The following changes since commit a95260486aa7e78d7c7194eba65cf03311ad94ad: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-09-13' into staging (2021-09-13 11:00:30 +0100) | 3 | Merge tag 'pull-tcg-20231023' of https://gitlab.com/rth7680/qemu into staging (2023-10-23 14:45:46 -0700) |
4 | 4 | ||
5 | are available in the Git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | https://github.com/legoater/qemu/ tags/pull-aspeed-20210913 | 7 | https://github.com/legoater/qemu/ tags/pull-aspeed-20231025 |
8 | 8 | ||
9 | for you to fetch changes up to d7add12e20fa8982f5932ff4dca317c5d2dfe7d9: | 9 | for you to fetch changes up to dd41ce7a6f13ad4f45ebaf52b9fa91fe5fc961df: |
10 | 10 | ||
11 | hw/arm/aspeed: Add Fuji machine type (2021-09-13 15:19:20 +0200) | 11 | hw/arm/aspeed: Move AspeedSoCState::cpu/vic to Aspeed2400SoCState (2023-10-25 09:52:44 +0200) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Aspeed patches : | 14 | aspeed queue: |
15 | 15 | ||
16 | * MAC enablement fixes (Guenter) | 16 | * Update of Andrew's email |
17 | * Watchdog and pca9552 fixes (Andrew) | 17 | * Split of AspeedSoCState per 2400/2600/10x0 |
18 | * GPIO fixes (Joel) | ||
19 | * AST2600A3 SoC and DPS310 models (Joel) | ||
20 | * New Fuji BMC machine (Peter) | ||
21 | 18 | ||
22 | ---------------------------------------------------------------- | 19 | ---------------------------------------------------------------- |
23 | Andrew Jeffery (3): | 20 | Andrew Jeffery (1): |
24 | watchdog: aspeed: Sanitize control register values | 21 | MAINTAINERS: aspeed: Update Andrew's email address |
25 | watchdog: aspeed: Fix sequential control writes | ||
26 | misc/pca9552: Fix LED status register indexing in pca955x_get_led() | ||
27 | 22 | ||
28 | Guenter Roeck (2): | 23 | Philippe Mathieu-Daudé (11): |
29 | hw: arm: aspeed: Enable eth0 interface for aspeed-ast2600-evb | 24 | hw/arm/aspeed: Extract code common to all boards to a common file |
30 | hw: arm: aspeed: Enable mac0/1 instead of mac1/2 for g220a | 25 | hw/arm/aspeed: Rename aspeed_soc_init() as AST2400/2500 specific |
26 | hw/arm/aspeed: Rename aspeed_soc_realize() as AST2400/2500 specific | ||
27 | hw/arm/aspeed: Dynamically allocate AspeedMachineState::soc field | ||
28 | hw/arm/aspeed: Introduce TYPE_ASPEED10X0_SOC | ||
29 | hw/arm/aspeed: Introduce TYPE_ASPEED2600_SOC | ||
30 | hw/arm/aspeed: Introduce TYPE_ASPEED2400_SOC | ||
31 | hw/arm/aspeed: Check 'memory' link is set in common aspeed_soc_realize | ||
32 | hw/arm/aspeed: Move AspeedSoCState::armv7m to Aspeed10x0SoCState | ||
33 | hw/arm/aspeed: Move AspeedSoCState::a7mpcore to Aspeed2600SoCState | ||
34 | hw/arm/aspeed: Move AspeedSoCState::cpu/vic to Aspeed2400SoCState | ||
31 | 35 | ||
32 | Joel Stanley (6): | 36 | MAINTAINERS | 2 +- |
33 | hw: aspeed_gpio: Simplify 1.8V defines | 37 | include/hw/arm/aspeed_soc.h | 35 +++++- |
34 | hw: aspeed_gpio: Clarify GPIO controller name | 38 | hw/arm/aspeed.c | 101 +++++++-------- |
35 | arm/aspeed: rainier: Add i2c eeproms and muxes | 39 | hw/arm/aspeed_ast10x0.c | 53 ++++---- |
36 | aspeed: Emulate the AST2600A3 | 40 | hw/arm/{aspeed_soc.c => aspeed_ast2400.c} | 197 +++++++----------------------- |
37 | hw/misc: Add Infineon DPS310 sensor model | 41 | hw/arm/aspeed_ast2600.c | 75 ++++++------ |
38 | arm/aspeed: Add DPS310 to Witherspoon and Rainier | 42 | hw/arm/aspeed_soc_common.c | 154 +++++++++++++++++++++++ |
43 | hw/arm/fby35.c | 27 ++-- | ||
44 | hw/arm/meson.build | 3 +- | ||
45 | 9 files changed, 363 insertions(+), 284 deletions(-) | ||
46 | rename hw/arm/{aspeed_soc.c => aspeed_ast2400.c} (76%) | ||
47 | create mode 100644 hw/arm/aspeed_soc_common.c | ||
39 | 48 | ||
40 | Peter Delevoryas (3): | ||
41 | hw/arm/aspeed: Initialize AST2600 UART clock selection registers | ||
42 | hw/arm/aspeed: Allow machine to set UART default | ||
43 | hw/arm/aspeed: Add Fuji machine type | ||
44 | |||
45 | include/hw/arm/aspeed.h | 1 + | ||
46 | include/hw/arm/aspeed_soc.h | 1 + | ||
47 | include/hw/misc/aspeed_scu.h | 2 + | ||
48 | include/hw/watchdog/wdt_aspeed.h | 1 + | ||
49 | hw/arm/aspeed.c | 175 ++++++++++++++++++++++++++++-- | ||
50 | hw/arm/aspeed_ast2600.c | 14 +-- | ||
51 | hw/arm/aspeed_soc.c | 8 +- | ||
52 | hw/gpio/aspeed_gpio.c | 97 +++++++++-------- | ||
53 | hw/misc/aspeed_scu.c | 40 +++++-- | ||
54 | hw/misc/pca9552.c | 2 +- | ||
55 | hw/sensor/dps310.c | 225 +++++++++++++++++++++++++++++++++++++++ | ||
56 | hw/watchdog/wdt_aspeed.c | 26 ++++- | ||
57 | hw/arm/Kconfig | 1 + | ||
58 | hw/sensor/Kconfig | 4 + | ||
59 | hw/sensor/meson.build | 1 + | ||
60 | 15 files changed, 522 insertions(+), 76 deletions(-) | ||
61 | create mode 100644 hw/sensor/dps310.c | ||
62 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Guenter Roeck <linux@roeck-us.net> | ||
2 | 1 | ||
3 | Commit 7582591ae7 ("aspeed: Support AST2600A1 silicon revision") switched | ||
4 | the silicon revision for AST2600 to revision A1. On revision A1, the first | ||
5 | Ethernet interface is operational. Enable it. | ||
6 | |||
7 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | ||
8 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Message-Id: <20210808200457.889955-1-linux@roeck-us.net> | ||
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | --- | ||
13 | hw/arm/aspeed.c | 3 ++- | ||
14 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/arm/aspeed.c | ||
19 | +++ b/hw/arm/aspeed.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | ||
21 | amc->fmc_model = "w25q512jv"; | ||
22 | amc->spi_model = "mx66u51235f"; | ||
23 | amc->num_cs = 1; | ||
24 | - amc->macs_mask = ASPEED_MAC1_ON | ASPEED_MAC2_ON | ASPEED_MAC3_ON; | ||
25 | + amc->macs_mask = ASPEED_MAC0_ON | ASPEED_MAC1_ON | ASPEED_MAC2_ON | | ||
26 | + ASPEED_MAC3_ON; | ||
27 | amc->i2c_init = ast2600_evb_i2c_init; | ||
28 | mc->default_ram_size = 1 * GiB; | ||
29 | mc->default_cpus = mc->min_cpus = mc->max_cpus = | ||
30 | -- | ||
31 | 2.31.1 | ||
32 | |||
33 | diff view generated by jsdifflib |
1 | From: Guenter Roeck <linux@roeck-us.net> | 1 | From: Andrew Jeffery <andrew@codeconstruct.com.au> |
---|---|---|---|
2 | 2 | ||
3 | According to its dts file in the Linux kernel, we need mac0 and mac1 enabled | 3 | I've changed employers, have company email that deals with patch-based |
4 | instead of mac1 and mac2. Also, g220a is based on aspeed-g5 (ast2500) which | 4 | workflows without too much of a headache, and am trying to steer some |
5 | doesn't even have the third interface. | 5 | content out of my personal mail. |
6 | 6 | ||
7 | Signed-off-by: Guenter Roeck <linux@roeck-us.net> | 7 | Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au> |
8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
9 | Message-Id: <20210810035742.550391-1-linux@roeck-us.net> | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
11 | --- | 9 | --- |
12 | hw/arm/aspeed.c | 2 +- | 10 | MAINTAINERS | 2 +- |
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | 1 file changed, 1 insertion(+), 1 deletion(-) |
14 | 12 | ||
15 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 13 | diff --git a/MAINTAINERS b/MAINTAINERS |
16 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/aspeed.c | 15 | --- a/MAINTAINERS |
18 | +++ b/hw/arm/aspeed.c | 16 | +++ b/MAINTAINERS |
19 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_g220a_class_init(ObjectClass *oc, void *data) | 17 | @@ -XXX,XX +XXX,XX @@ F: docs/system/arm/emcraft-sf2.rst |
20 | amc->fmc_model = "n25q512a"; | 18 | ASPEED BMCs |
21 | amc->spi_model = "mx25l25635e"; | 19 | M: Cédric Le Goater <clg@kaod.org> |
22 | amc->num_cs = 2; | 20 | M: Peter Maydell <peter.maydell@linaro.org> |
23 | - amc->macs_mask = ASPEED_MAC1_ON | ASPEED_MAC2_ON; | 21 | -R: Andrew Jeffery <andrew@aj.id.au> |
24 | + amc->macs_mask = ASPEED_MAC0_ON | ASPEED_MAC1_ON; | 22 | +R: Andrew Jeffery <andrew@codeconstruct.com.au> |
25 | amc->i2c_init = g220a_bmc_i2c_init; | 23 | R: Joel Stanley <joel@jms.id.au> |
26 | mc->default_ram_size = 1024 * MiB; | 24 | L: qemu-arm@nongnu.org |
27 | mc->default_cpus = mc->min_cpus = mc->max_cpus = | 25 | S: Maintained |
28 | -- | 26 | -- |
29 | 2.31.1 | 27 | 2.41.0 |
30 | 28 | ||
31 | 29 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This contains some hardcoded register values that were obtained from the | 3 | aspeed_soc.c contains definitions specific to the AST2400 |
4 | hardware after reading the temperature. | 4 | and AST2500 SoCs, but also some definitions for other AST |
5 | 5 | SoCs: move them to a common file. | |
6 | It does enough to test the Linux kernel driver. The FIFO mode, IRQs and | 6 | |
7 | operation modes other than the default as used by Linux are not modelled. | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | 8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | |
9 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
10 | Message-Id: <20210616073358.750472-2-joel@jms.id.au> | ||
11 | [ clg: - Fixed sequential reading | ||
12 | - Reworked regs_reset_state array | ||
13 | - Moved model under hw/sensor/ ] | ||
14 | Message-Id: <20210629142336.750058-4-clg@kaod.org> | ||
15 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
16 | --- | 10 | --- |
17 | hw/sensor/dps310.c | 225 ++++++++++++++++++++++++++++++++++++++++++ | 11 | hw/arm/aspeed_soc.c | 96 ------------------------------- |
18 | hw/arm/Kconfig | 1 + | 12 | hw/arm/aspeed_soc_common.c | 114 +++++++++++++++++++++++++++++++++++++ |
19 | hw/sensor/Kconfig | 4 + | 13 | hw/arm/meson.build | 1 + |
20 | hw/sensor/meson.build | 1 + | 14 | 3 files changed, 115 insertions(+), 96 deletions(-) |
21 | 4 files changed, 231 insertions(+) | 15 | create mode 100644 hw/arm/aspeed_soc_common.c |
22 | create mode 100644 hw/sensor/dps310.c | 16 | |
23 | 17 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | |
24 | diff --git a/hw/sensor/dps310.c b/hw/sensor/dps310.c | 18 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/arm/aspeed_soc.c | ||
20 | +++ b/hw/arm/aspeed_soc.c | ||
21 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_register_types(void) | ||
22 | }; | ||
23 | |||
24 | type_init(aspeed_soc_register_types); | ||
25 | - | ||
26 | -qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev) | ||
27 | -{ | ||
28 | - return ASPEED_SOC_GET_CLASS(s)->get_irq(s, dev); | ||
29 | -} | ||
30 | - | ||
31 | -bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp) | ||
32 | -{ | ||
33 | - AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
34 | - SerialMM *smm; | ||
35 | - | ||
36 | - for (int i = 0, uart = ASPEED_DEV_UART1; i < sc->uarts_num; i++, uart++) { | ||
37 | - smm = &s->uart[i]; | ||
38 | - | ||
39 | - /* Chardev property is set by the machine. */ | ||
40 | - qdev_prop_set_uint8(DEVICE(smm), "regshift", 2); | ||
41 | - qdev_prop_set_uint32(DEVICE(smm), "baudbase", 38400); | ||
42 | - qdev_set_legacy_instance_id(DEVICE(smm), sc->memmap[uart], 2); | ||
43 | - qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN); | ||
44 | - if (!sysbus_realize(SYS_BUS_DEVICE(smm), errp)) { | ||
45 | - return false; | ||
46 | - } | ||
47 | - | ||
48 | - sysbus_connect_irq(SYS_BUS_DEVICE(smm), 0, aspeed_soc_get_irq(s, uart)); | ||
49 | - aspeed_mmio_map(s, SYS_BUS_DEVICE(smm), 0, sc->memmap[uart]); | ||
50 | - } | ||
51 | - | ||
52 | - return true; | ||
53 | -} | ||
54 | - | ||
55 | -void aspeed_soc_uart_set_chr(AspeedSoCState *s, int dev, Chardev *chr) | ||
56 | -{ | ||
57 | - AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
58 | - int i = dev - ASPEED_DEV_UART1; | ||
59 | - | ||
60 | - g_assert(0 <= i && i < ARRAY_SIZE(s->uart) && i < sc->uarts_num); | ||
61 | - qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr); | ||
62 | -} | ||
63 | - | ||
64 | -/* | ||
65 | - * SDMC should be realized first to get correct RAM size and max size | ||
66 | - * values | ||
67 | - */ | ||
68 | -bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp) | ||
69 | -{ | ||
70 | - AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
71 | - ram_addr_t ram_size, max_ram_size; | ||
72 | - | ||
73 | - ram_size = object_property_get_uint(OBJECT(&s->sdmc), "ram-size", | ||
74 | - &error_abort); | ||
75 | - max_ram_size = object_property_get_uint(OBJECT(&s->sdmc), "max-ram-size", | ||
76 | - &error_abort); | ||
77 | - | ||
78 | - memory_region_init(&s->dram_container, OBJECT(s), "ram-container", | ||
79 | - max_ram_size); | ||
80 | - memory_region_add_subregion(&s->dram_container, 0, s->dram_mr); | ||
81 | - | ||
82 | - /* | ||
83 | - * Add a memory region beyond the RAM region to let firmwares scan | ||
84 | - * the address space with load/store and guess how much RAM the | ||
85 | - * SoC has. | ||
86 | - */ | ||
87 | - if (ram_size < max_ram_size) { | ||
88 | - DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE); | ||
89 | - | ||
90 | - qdev_prop_set_string(dev, "name", "ram-empty"); | ||
91 | - qdev_prop_set_uint64(dev, "size", max_ram_size - ram_size); | ||
92 | - if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp)) { | ||
93 | - return false; | ||
94 | - } | ||
95 | - | ||
96 | - memory_region_add_subregion_overlap(&s->dram_container, ram_size, | ||
97 | - sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0), -1000); | ||
98 | - } | ||
99 | - | ||
100 | - memory_region_add_subregion(s->memory, | ||
101 | - sc->memmap[ASPEED_DEV_SDRAM], &s->dram_container); | ||
102 | - return true; | ||
103 | -} | ||
104 | - | ||
105 | -void aspeed_mmio_map(AspeedSoCState *s, SysBusDevice *dev, int n, hwaddr addr) | ||
106 | -{ | ||
107 | - memory_region_add_subregion(s->memory, addr, | ||
108 | - sysbus_mmio_get_region(dev, n)); | ||
109 | -} | ||
110 | - | ||
111 | -void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev, | ||
112 | - const char *name, hwaddr addr, uint64_t size) | ||
113 | -{ | ||
114 | - qdev_prop_set_string(DEVICE(dev), "name", name); | ||
115 | - qdev_prop_set_uint64(DEVICE(dev), "size", size); | ||
116 | - sysbus_realize(dev, &error_abort); | ||
117 | - | ||
118 | - memory_region_add_subregion_overlap(s->memory, addr, | ||
119 | - sysbus_mmio_get_region(dev, 0), -1000); | ||
120 | -} | ||
121 | diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c | ||
25 | new file mode 100644 | 122 | new file mode 100644 |
26 | index XXXXXXX..XXXXXXX | 123 | index XXXXXXX..XXXXXXX |
27 | --- /dev/null | 124 | --- /dev/null |
28 | +++ b/hw/sensor/dps310.c | 125 | +++ b/hw/arm/aspeed_soc_common.c |
29 | @@ -XXX,XX +XXX,XX @@ | 126 | @@ -XXX,XX +XXX,XX @@ |
30 | +// SPDX-License-Identifier: GPL-2.0-or-later | ||
31 | +/* | 127 | +/* |
32 | + * Copyright 2017-2021 Joel Stanley <joel@jms.id.au>, IBM Corporation | 128 | + * ASPEED SoC family |
33 | + * | 129 | + * |
34 | + * Infineon DPS310 temperature and humidity sensor | 130 | + * Andrew Jeffery <andrew@aj.id.au> |
131 | + * Jeremy Kerr <jk@ozlabs.org> | ||
35 | + * | 132 | + * |
36 | + * https://www.infineon.com/cms/en/product/sensor/pressure-sensors/pressure-sensors-for-iot/dps310/ | 133 | + * Copyright 2016 IBM Corp. |
134 | + * | ||
135 | + * This code is licensed under the GPL version 2 or later. See | ||
136 | + * the COPYING file in the top-level directory. | ||
37 | + */ | 137 | + */ |
38 | + | 138 | + |
39 | +#include "qemu/osdep.h" | 139 | +#include "qemu/osdep.h" |
40 | +#include "qemu/log.h" | ||
41 | +#include "hw/hw.h" | ||
42 | +#include "hw/i2c/i2c.h" | ||
43 | +#include "qapi/error.h" | 140 | +#include "qapi/error.h" |
44 | +#include "qapi/visitor.h" | 141 | +#include "hw/misc/unimp.h" |
45 | +#include "migration/vmstate.h" | 142 | +#include "hw/arm/aspeed_soc.h" |
46 | + | 143 | +#include "hw/char/serial.h" |
47 | +#define NUM_REGISTERS 0x33 | 144 | + |
48 | + | 145 | + |
49 | +typedef struct DPS310State { | 146 | +qemu_irq aspeed_soc_get_irq(AspeedSoCState *s, int dev) |
50 | + /*< private >*/ | 147 | +{ |
51 | + I2CSlave i2c; | 148 | + return ASPEED_SOC_GET_CLASS(s)->get_irq(s, dev); |
52 | + | 149 | +} |
53 | + /*< public >*/ | 150 | + |
54 | + uint8_t regs[NUM_REGISTERS]; | 151 | +bool aspeed_soc_uart_realize(AspeedSoCState *s, Error **errp) |
55 | + | 152 | +{ |
56 | + uint8_t len; | 153 | + AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); |
57 | + uint8_t pointer; | 154 | + SerialMM *smm; |
58 | + | 155 | + |
59 | +} DPS310State; | 156 | + for (int i = 0, uart = ASPEED_DEV_UART1; i < sc->uarts_num; i++, uart++) { |
60 | + | 157 | + smm = &s->uart[i]; |
61 | +#define TYPE_DPS310 "dps310" | 158 | + |
62 | +#define DPS310(obj) OBJECT_CHECK(DPS310State, (obj), TYPE_DPS310) | 159 | + /* Chardev property is set by the machine. */ |
63 | + | 160 | + qdev_prop_set_uint8(DEVICE(smm), "regshift", 2); |
64 | +#define DPS310_PRS_B2 0x00 | 161 | + qdev_prop_set_uint32(DEVICE(smm), "baudbase", 38400); |
65 | +#define DPS310_PRS_B1 0x01 | 162 | + qdev_set_legacy_instance_id(DEVICE(smm), sc->memmap[uart], 2); |
66 | +#define DPS310_PRS_B0 0x02 | 163 | + qdev_prop_set_uint8(DEVICE(smm), "endianness", DEVICE_LITTLE_ENDIAN); |
67 | +#define DPS310_TMP_B2 0x03 | 164 | + if (!sysbus_realize(SYS_BUS_DEVICE(smm), errp)) { |
68 | +#define DPS310_TMP_B1 0x04 | 165 | + return false; |
69 | +#define DPS310_TMP_B0 0x05 | 166 | + } |
70 | +#define DPS310_PRS_CFG 0x06 | 167 | + |
71 | +#define DPS310_TMP_CFG 0x07 | 168 | + sysbus_connect_irq(SYS_BUS_DEVICE(smm), 0, aspeed_soc_get_irq(s, uart)); |
72 | +#define DPS310_TMP_RATE_BITS (0x70) | 169 | + aspeed_mmio_map(s, SYS_BUS_DEVICE(smm), 0, sc->memmap[uart]); |
73 | +#define DPS310_MEAS_CFG 0x08 | ||
74 | +#define DPS310_MEAS_CTRL_BITS (0x07) | ||
75 | +#define DPS310_PRESSURE_EN BIT(0) | ||
76 | +#define DPS310_TEMP_EN BIT(1) | ||
77 | +#define DPS310_BACKGROUND BIT(2) | ||
78 | +#define DPS310_PRS_RDY BIT(4) | ||
79 | +#define DPS310_TMP_RDY BIT(5) | ||
80 | +#define DPS310_SENSOR_RDY BIT(6) | ||
81 | +#define DPS310_COEF_RDY BIT(7) | ||
82 | +#define DPS310_CFG_REG 0x09 | ||
83 | +#define DPS310_RESET 0x0c | ||
84 | +#define DPS310_RESET_MAGIC (BIT(0) | BIT(3)) | ||
85 | +#define DPS310_COEF_BASE 0x10 | ||
86 | +#define DPS310_COEF_LAST 0x21 | ||
87 | +#define DPS310_COEF_SRC 0x28 | ||
88 | + | ||
89 | +static void dps310_reset(DeviceState *dev) | ||
90 | +{ | ||
91 | + DPS310State *s = DPS310(dev); | ||
92 | + | ||
93 | + static const uint8_t regs_reset_state[sizeof(s->regs)] = { | ||
94 | + 0xfe, 0x2f, 0xee, 0x02, 0x69, 0xa6, 0x00, 0x80, 0xc7, 0x00, 0x00, 0x00, | ||
95 | + 0x00, 0x10, 0x00, 0x00, 0x0e, 0x1e, 0xdd, 0x13, 0xca, 0x5f, 0x21, 0x52, | ||
96 | + 0xf9, 0xc6, 0x04, 0xd1, 0xdb, 0x47, 0x00, 0x5b, 0xfb, 0x3a, 0x00, 0x00, | ||
97 | + 0x20, 0x49, 0x4e, 0xa5, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
98 | + 0x60, 0x15, 0x02 | ||
99 | + }; | ||
100 | + | ||
101 | + memcpy(s->regs, regs_reset_state, sizeof(s->regs)); | ||
102 | + s->pointer = 0; | ||
103 | + | ||
104 | + /* TODO: assert these after some timeout ? */ | ||
105 | + s->regs[DPS310_MEAS_CFG] = DPS310_COEF_RDY | DPS310_SENSOR_RDY | ||
106 | + | DPS310_TMP_RDY | DPS310_PRS_RDY; | ||
107 | +} | ||
108 | + | ||
109 | +static uint8_t dps310_read(DPS310State *s, uint8_t reg) | ||
110 | +{ | ||
111 | + if (reg >= sizeof(s->regs)) { | ||
112 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: register 0x%02x out of bounds\n", | ||
113 | + __func__, s->pointer); | ||
114 | + return 0xFF; | ||
115 | + } | 170 | + } |
116 | + | 171 | + |
117 | + switch (reg) { | 172 | + return true; |
118 | + case DPS310_PRS_B2: | 173 | +} |
119 | + case DPS310_PRS_B1: | 174 | + |
120 | + case DPS310_PRS_B0: | 175 | +void aspeed_soc_uart_set_chr(AspeedSoCState *s, int dev, Chardev *chr) |
121 | + case DPS310_TMP_B2: | 176 | +{ |
122 | + case DPS310_TMP_B1: | 177 | + AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); |
123 | + case DPS310_TMP_B0: | 178 | + int i = dev - ASPEED_DEV_UART1; |
124 | + case DPS310_PRS_CFG: | 179 | + |
125 | + case DPS310_TMP_CFG: | 180 | + g_assert(0 <= i && i < ARRAY_SIZE(s->uart) && i < sc->uarts_num); |
126 | + case DPS310_MEAS_CFG: | 181 | + qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr); |
127 | + case DPS310_CFG_REG: | 182 | +} |
128 | + case DPS310_COEF_BASE...DPS310_COEF_LAST: | 183 | + |
129 | + case DPS310_COEF_SRC: | 184 | +/* |
130 | + case 0x32: /* Undocumented register to indicate workaround not required */ | 185 | + * SDMC should be realized first to get correct RAM size and max size |
131 | + return s->regs[reg]; | 186 | + * values |
132 | + default: | 187 | + */ |
133 | + qemu_log_mask(LOG_UNIMP, "%s: register 0x%02x unimplemented\n", | 188 | +bool aspeed_soc_dram_init(AspeedSoCState *s, Error **errp) |
134 | + __func__, reg); | 189 | +{ |
135 | + return 0xFF; | 190 | + AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); |
191 | + ram_addr_t ram_size, max_ram_size; | ||
192 | + | ||
193 | + ram_size = object_property_get_uint(OBJECT(&s->sdmc), "ram-size", | ||
194 | + &error_abort); | ||
195 | + max_ram_size = object_property_get_uint(OBJECT(&s->sdmc), "max-ram-size", | ||
196 | + &error_abort); | ||
197 | + | ||
198 | + memory_region_init(&s->dram_container, OBJECT(s), "ram-container", | ||
199 | + max_ram_size); | ||
200 | + memory_region_add_subregion(&s->dram_container, 0, s->dram_mr); | ||
201 | + | ||
202 | + /* | ||
203 | + * Add a memory region beyond the RAM region to let firmwares scan | ||
204 | + * the address space with load/store and guess how much RAM the | ||
205 | + * SoC has. | ||
206 | + */ | ||
207 | + if (ram_size < max_ram_size) { | ||
208 | + DeviceState *dev = qdev_new(TYPE_UNIMPLEMENTED_DEVICE); | ||
209 | + | ||
210 | + qdev_prop_set_string(dev, "name", "ram-empty"); | ||
211 | + qdev_prop_set_uint64(dev, "size", max_ram_size - ram_size); | ||
212 | + if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp)) { | ||
213 | + return false; | ||
214 | + } | ||
215 | + | ||
216 | + memory_region_add_subregion_overlap(&s->dram_container, ram_size, | ||
217 | + sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0), -1000); | ||
136 | + } | 218 | + } |
137 | +} | 219 | + |
138 | + | 220 | + memory_region_add_subregion(s->memory, |
139 | +static void dps310_write(DPS310State *s, uint8_t reg, uint8_t data) | 221 | + sc->memmap[ASPEED_DEV_SDRAM], &s->dram_container); |
140 | +{ | 222 | + return true; |
141 | + if (reg >= sizeof(s->regs)) { | 223 | +} |
142 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: register %d out of bounds\n", | 224 | + |
143 | + __func__, s->pointer); | 225 | +void aspeed_mmio_map(AspeedSoCState *s, SysBusDevice *dev, int n, hwaddr addr) |
144 | + return; | 226 | +{ |
145 | + } | 227 | + memory_region_add_subregion(s->memory, addr, |
146 | + | 228 | + sysbus_mmio_get_region(dev, n)); |
147 | + switch (reg) { | 229 | +} |
148 | + case DPS310_RESET: | 230 | + |
149 | + if (data == DPS310_RESET_MAGIC) { | 231 | +void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev, |
150 | + device_cold_reset(DEVICE(s)); | 232 | + const char *name, hwaddr addr, uint64_t size) |
151 | + } | 233 | +{ |
152 | + break; | 234 | + qdev_prop_set_string(DEVICE(dev), "name", name); |
153 | + case DPS310_PRS_CFG: | 235 | + qdev_prop_set_uint64(DEVICE(dev), "size", size); |
154 | + case DPS310_TMP_CFG: | 236 | + sysbus_realize(dev, &error_abort); |
155 | + case DPS310_MEAS_CFG: | 237 | + |
156 | + case DPS310_CFG_REG: | 238 | + memory_region_add_subregion_overlap(s->memory, addr, |
157 | + s->regs[reg] = data; | 239 | + sysbus_mmio_get_region(dev, 0), -1000); |
158 | + break; | 240 | +} |
159 | + default: | 241 | diff --git a/hw/arm/meson.build b/hw/arm/meson.build |
160 | + qemu_log_mask(LOG_UNIMP, "%s: register 0x%02x unimplemented\n", | ||
161 | + __func__, reg); | ||
162 | + return; | ||
163 | + } | ||
164 | +} | ||
165 | + | ||
166 | +static uint8_t dps310_rx(I2CSlave *i2c) | ||
167 | +{ | ||
168 | + DPS310State *s = DPS310(i2c); | ||
169 | + | ||
170 | + if (s->len == 1) { | ||
171 | + return dps310_read(s, s->pointer++); | ||
172 | + } else { | ||
173 | + return 0xFF; | ||
174 | + } | ||
175 | +} | ||
176 | + | ||
177 | +static int dps310_tx(I2CSlave *i2c, uint8_t data) | ||
178 | +{ | ||
179 | + DPS310State *s = DPS310(i2c); | ||
180 | + | ||
181 | + if (s->len == 0) { | ||
182 | + /* | ||
183 | + * first byte is the register pointer for a read or write | ||
184 | + * operation | ||
185 | + */ | ||
186 | + s->pointer = data; | ||
187 | + s->len++; | ||
188 | + } else if (s->len == 1) { | ||
189 | + dps310_write(s, s->pointer++, data); | ||
190 | + } | ||
191 | + | ||
192 | + return 0; | ||
193 | +} | ||
194 | + | ||
195 | +static int dps310_event(I2CSlave *i2c, enum i2c_event event) | ||
196 | +{ | ||
197 | + DPS310State *s = DPS310(i2c); | ||
198 | + | ||
199 | + switch (event) { | ||
200 | + case I2C_START_SEND: | ||
201 | + s->pointer = 0xFF; | ||
202 | + s->len = 0; | ||
203 | + break; | ||
204 | + case I2C_START_RECV: | ||
205 | + if (s->len != 1) { | ||
206 | + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid recv sequence\n", | ||
207 | + __func__); | ||
208 | + } | ||
209 | + break; | ||
210 | + default: | ||
211 | + break; | ||
212 | + } | ||
213 | + | ||
214 | + return 0; | ||
215 | +} | ||
216 | + | ||
217 | +static const VMStateDescription vmstate_dps310 = { | ||
218 | + .name = "DPS310", | ||
219 | + .version_id = 0, | ||
220 | + .minimum_version_id = 0, | ||
221 | + .fields = (VMStateField[]) { | ||
222 | + VMSTATE_UINT8(len, DPS310State), | ||
223 | + VMSTATE_UINT8_ARRAY(regs, DPS310State, NUM_REGISTERS), | ||
224 | + VMSTATE_UINT8(pointer, DPS310State), | ||
225 | + VMSTATE_I2C_SLAVE(i2c, DPS310State), | ||
226 | + VMSTATE_END_OF_LIST() | ||
227 | + } | ||
228 | +}; | ||
229 | + | ||
230 | +static void dps310_class_init(ObjectClass *klass, void *data) | ||
231 | +{ | ||
232 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
233 | + I2CSlaveClass *k = I2C_SLAVE_CLASS(klass); | ||
234 | + | ||
235 | + k->event = dps310_event; | ||
236 | + k->recv = dps310_rx; | ||
237 | + k->send = dps310_tx; | ||
238 | + dc->reset = dps310_reset; | ||
239 | + dc->vmsd = &vmstate_dps310; | ||
240 | +} | ||
241 | + | ||
242 | +static const TypeInfo dps310_info = { | ||
243 | + .name = TYPE_DPS310, | ||
244 | + .parent = TYPE_I2C_SLAVE, | ||
245 | + .instance_size = sizeof(DPS310State), | ||
246 | + .class_init = dps310_class_init, | ||
247 | +}; | ||
248 | + | ||
249 | +static void dps310_register_types(void) | ||
250 | +{ | ||
251 | + type_register_static(&dps310_info); | ||
252 | +} | ||
253 | + | ||
254 | +type_init(dps310_register_types) | ||
255 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
256 | index XXXXXXX..XXXXXXX 100644 | 242 | index XXXXXXX..XXXXXXX 100644 |
257 | --- a/hw/arm/Kconfig | 243 | --- a/hw/arm/meson.build |
258 | +++ b/hw/arm/Kconfig | 244 | +++ b/hw/arm/meson.build |
259 | @@ -XXX,XX +XXX,XX @@ config ASPEED_SOC | 245 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_FSL_IMX6', if_true: files('fsl-imx6.c')) |
260 | select DS1338 | 246 | arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( |
261 | select FTGMAC100 | 247 | 'aspeed_soc.c', |
262 | select I2C | 248 | 'aspeed.c', |
263 | + select DPS310 | 249 | + 'aspeed_soc_common.c', |
264 | select PCA9552 | 250 | 'aspeed_ast2600.c', |
265 | select SERIAL | 251 | 'aspeed_ast10x0.c', |
266 | select SMBUS_EEPROM | 252 | 'aspeed_eeprom.c', |
267 | diff --git a/hw/sensor/Kconfig b/hw/sensor/Kconfig | ||
268 | index XXXXXXX..XXXXXXX 100644 | ||
269 | --- a/hw/sensor/Kconfig | ||
270 | +++ b/hw/sensor/Kconfig | ||
271 | @@ -XXX,XX +XXX,XX @@ config TMP421 | ||
272 | bool | ||
273 | depends on I2C | ||
274 | |||
275 | +config DPS310 | ||
276 | + bool | ||
277 | + depends on I2C | ||
278 | + | ||
279 | config EMC141X | ||
280 | bool | ||
281 | depends on I2C | ||
282 | diff --git a/hw/sensor/meson.build b/hw/sensor/meson.build | ||
283 | index XXXXXXX..XXXXXXX 100644 | ||
284 | --- a/hw/sensor/meson.build | ||
285 | +++ b/hw/sensor/meson.build | ||
286 | @@ -XXX,XX +XXX,XX @@ | ||
287 | softmmu_ss.add(when: 'CONFIG_TMP105', if_true: files('tmp105.c')) | ||
288 | softmmu_ss.add(when: 'CONFIG_TMP421', if_true: files('tmp421.c')) | ||
289 | +softmmu_ss.add(when: 'CONFIG_DPS310', if_true: files('dps310.c')) | ||
290 | softmmu_ss.add(when: 'CONFIG_EMC141X', if_true: files('emc141x.c')) | ||
291 | softmmu_ss.add(when: 'CONFIG_ADM1272', if_true: files('adm1272.c')) | ||
292 | softmmu_ss.add(when: 'CONFIG_MAX34451', if_true: files('max34451.c')) | ||
293 | -- | 253 | -- |
294 | 2.31.1 | 254 | 2.41.0 |
295 | 255 | ||
296 | 256 | diff view generated by jsdifflib |
1 | From: Peter Delevoryas <pdel@fb.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | UART5 is typically used as the default debug UART on the AST2600, but | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | UART1 is also designed to be a debug UART. All the AST2600 UART's have | 4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
5 | semi-configurable clock rates through registers in the System Control | ||
6 | Unit (SCU), but only UART5 works out of the box with zero-initialized | ||
7 | values. The rest of the UART's expect a few of the registers to be | ||
8 | initialized to non-zero values, or else the clock rate calculation will | ||
9 | yield zero or undefined (due to a divide-by-zero). | ||
10 | |||
11 | For reference, the U-Boot clock rate driver here shows the calculation: | ||
12 | |||
13 | https://github.com/facebook/openbmc-uboot/blob/15f7e0dc01d8/drivers/clk/aspeed/clk_ast2600.c#L357 | ||
14 | |||
15 | To summarize, UART5 allows selection from 4 rates: 24 MHz, 192 MHz, 24 / | ||
16 | 13 MHz, and 192 / 13 MHz. The other UART's allow selecting either the | ||
17 | "low" rate (UARTCLK) or the "high" rate (HUARTCLK). UARTCLK and HUARTCLK | ||
18 | are configurable themselves: | ||
19 | |||
20 | UARTCLK = UXCLK * R / (N * 2) | ||
21 | HUARTCLK = HUXCLK * HR / (HN * 2) | ||
22 | |||
23 | UXCLK and HUXCLK are also configurable, and depend on the APLL and/or | ||
24 | HPLL clock rates, which also derive from complicated calculations. Long | ||
25 | story short, there's lots of multiplication and division from | ||
26 | configurable registers, and most of these registers are zero-initialized | ||
27 | in QEMU, which at best is unexpected and at worst causes this clock rate | ||
28 | driver to hang from divide-by-zero's. This can also be difficult to | ||
29 | diagnose, because it may cause U-Boot to hang before serial console | ||
30 | initialization completes, requiring intervention from gdb. | ||
31 | |||
32 | This change just initializes all of these registers with default values | ||
33 | from the datasheet. | ||
34 | |||
35 | To test this, I used Facebook's AST2600 OpenBMC image for "fuji", with | ||
36 | the following diff applied (because fuji uses UART1 for console output, | ||
37 | not UART5). | ||
38 | |||
39 | @@ -323,8 +323,8 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
40 | } | ||
41 | |||
42 | /* UART - attach an 8250 to the IO space as our UART5 */ | ||
43 | - serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2, | ||
44 | - aspeed_soc_get_irq(s, ASPEED_DEV_UART5), | ||
45 | + serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART1], 2, | ||
46 | + aspeed_soc_get_irq(s, ASPEED_DEV_UART1), | ||
47 | 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN); | ||
48 | |||
49 | /* I2C */ | ||
50 | |||
51 | Without these clock rate registers being initialized, U-Boot hangs in | ||
52 | the clock rate driver from a divide-by-zero, because the UART1 clock | ||
53 | rate register reads return zero, and there's no console output. After | ||
54 | initializing them with default values, fuji boots successfully. | ||
55 | |||
56 | Signed-off-by: Peter Delevoryas <pdel@fb.com> | ||
57 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
58 | [ clg: Removed _PARAM suffix ] | ||
59 | Message-Id: <20210906134023.3711031-2-pdel@fb.com> | ||
60 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
61 | --- | 6 | --- |
62 | hw/misc/aspeed_scu.c | 4 ++++ | 7 | hw/arm/aspeed_soc.c | 6 +++--- |
63 | 1 file changed, 4 insertions(+) | 8 | 1 file changed, 3 insertions(+), 3 deletions(-) |
64 | 9 | ||
65 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | 10 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
66 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
67 | --- a/hw/misc/aspeed_scu.c | 12 | --- a/hw/arm/aspeed_soc.c |
68 | +++ b/hw/misc/aspeed_scu.c | 13 | +++ b/hw/arm/aspeed_soc.c |
69 | @@ -XXX,XX +XXX,XX @@ | 14 | @@ -XXX,XX +XXX,XX @@ static qemu_irq aspeed_soc_ast2400_get_irq(AspeedSoCState *s, int dev) |
70 | #define AST2600_CLK_SEL3 TO_REG(0x308) | 15 | return qdev_get_gpio_in(DEVICE(&s->vic), sc->irqmap[dev]); |
71 | #define AST2600_CLK_SEL4 TO_REG(0x310) | 16 | } |
72 | #define AST2600_CLK_SEL5 TO_REG(0x314) | 17 | |
73 | +#define AST2600_UARTCLK TO_REG(0x338) | 18 | -static void aspeed_soc_init(Object *obj) |
74 | +#define AST2600_HUARTCLK TO_REG(0x33C) | 19 | +static void aspeed_ast2400_soc_init(Object *obj) |
75 | #define AST2600_HW_STRAP1 TO_REG(0x500) | 20 | { |
76 | #define AST2600_HW_STRAP1_CLR TO_REG(0x504) | 21 | AspeedSoCState *s = ASPEED_SOC(obj); |
77 | #define AST2600_HW_STRAP1_PROT TO_REG(0x508) | 22 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); |
78 | @@ -XXX,XX +XXX,XX @@ static const uint32_t ast2600_a3_resets[ASPEED_AST2600_SCU_NR_REGS] = { | 23 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data) |
79 | [AST2600_CLK_SEL3] = 0x00000000, | 24 | static const TypeInfo aspeed_soc_ast2400_type_info = { |
80 | [AST2600_CLK_SEL4] = 0xF3F40000, | 25 | .name = "ast2400-a1", |
81 | [AST2600_CLK_SEL5] = 0x30000000, | 26 | .parent = TYPE_ASPEED_SOC, |
82 | + [AST2600_UARTCLK] = 0x00014506, | 27 | - .instance_init = aspeed_soc_init, |
83 | + [AST2600_HUARTCLK] = 0x000145C0, | 28 | + .instance_init = aspeed_ast2400_soc_init, |
84 | [AST2600_CHIP_ID0] = 0x1234ABCD, | 29 | .instance_size = sizeof(AspeedSoCState), |
85 | [AST2600_CHIP_ID1] = 0x88884444, | 30 | .class_init = aspeed_soc_ast2400_class_init, |
31 | }; | ||
32 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data) | ||
33 | static const TypeInfo aspeed_soc_ast2500_type_info = { | ||
34 | .name = "ast2500-a1", | ||
35 | .parent = TYPE_ASPEED_SOC, | ||
36 | - .instance_init = aspeed_soc_init, | ||
37 | + .instance_init = aspeed_ast2400_soc_init, | ||
38 | .instance_size = sizeof(AspeedSoCState), | ||
39 | .class_init = aspeed_soc_ast2500_class_init, | ||
86 | }; | 40 | }; |
87 | -- | 41 | -- |
88 | 2.31.1 | 42 | 2.41.0 |
89 | 43 | ||
90 | 44 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Witherspoon uses the DPS310 as a temperature sensor. Rainier uses it as | 3 | Keep aspeed_soc_class_init() generic, set the realize handler |
4 | a temperature and humidity sensor. | 4 | to aspeed_ast2400_soc_realize() in each 2400/2500 class_init. |
5 | 5 | ||
6 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
8 | Message-Id: <20210629142336.750058-5-clg@kaod.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 | hw/arm/aspeed.c | 4 ++-- | 10 | hw/arm/aspeed_soc.c | 15 +++++++++++---- |
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | 11 | 1 file changed, 11 insertions(+), 4 deletions(-) |
13 | 12 | ||
14 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 13 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c |
15 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/aspeed.c | 15 | --- a/hw/arm/aspeed_soc.c |
17 | +++ b/hw/arm/aspeed.c | 16 | +++ b/hw/arm/aspeed_soc.c |
18 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc) | 17 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj) |
19 | 18 | object_initialize_child(obj, "video", &s->video, TYPE_UNIMPLEMENTED_DEVICE); | |
20 | /* Bus 3: TODO bmp280@77 */ | 19 | } |
21 | /* Bus 3: TODO max31785@52 */ | 20 | |
22 | - /* Bus 3: TODO dps310@76 */ | 21 | -static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
23 | dev = DEVICE(i2c_slave_new(TYPE_PCA9552, 0x60)); | 22 | +static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp) |
24 | qdev_prop_set_string(dev, "description", "pca1"); | 23 | { |
25 | i2c_slave_realize_and_unref(I2C_SLAVE(dev), | 24 | int i; |
26 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc) | 25 | AspeedSoCState *s = ASPEED_SOC(dev); |
27 | qdev_connect_gpio_out(dev, pca1_leds[i].gpio_id, | 26 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) |
28 | qdev_get_gpio_in(DEVICE(led), 0)); | 27 | { |
29 | } | 28 | DeviceClass *dc = DEVICE_CLASS(oc); |
30 | + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3), "dps310", 0x76); | 29 | |
31 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), "tmp423", 0x4c); | 30 | - dc->realize = aspeed_soc_realize; |
32 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), "tmp423", 0x4c); | 31 | - /* Reason: Uses serial_hds and nd_table in realize() directly */ |
33 | 32 | - dc->user_creatable = false; | |
34 | @@ -XXX,XX +XXX,XX @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) | 33 | device_class_set_props(dc, aspeed_soc_properties); |
35 | aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB); | 34 | } |
36 | aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB); | 35 | |
37 | 36 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_soc_type_info = { | |
38 | - /* Bus 7: TODO dps310@76 */ | 37 | static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data) |
39 | /* Bus 7: TODO max31785@52 */ | 38 | { |
40 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "pca9552", 0x61); | 39 | AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc); |
41 | + i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), "dps310", 0x76); | 40 | + DeviceClass *dc = DEVICE_CLASS(oc); |
42 | /* Bus 7: TODO si7021-a20@20 */ | 41 | + |
43 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105, | 42 | + dc->realize = aspeed_ast2400_soc_realize; |
44 | 0x48); | 43 | + /* Reason: Uses serial_hds and nd_table in realize() directly */ |
44 | + dc->user_creatable = false; | ||
45 | |||
46 | sc->name = "ast2400-a1"; | ||
47 | sc->cpu_type = ARM_CPU_TYPE_NAME("arm926"); | ||
48 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_soc_ast2400_type_info = { | ||
49 | static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data) | ||
50 | { | ||
51 | AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc); | ||
52 | + DeviceClass *dc = DEVICE_CLASS(oc); | ||
53 | + | ||
54 | + dc->realize = aspeed_ast2400_soc_realize; | ||
55 | + /* Reason: Uses serial_hds and nd_table in realize() directly */ | ||
56 | + dc->user_creatable = false; | ||
57 | |||
58 | sc->name = "ast2500-a1"; | ||
59 | sc->cpu_type = ARM_CPU_TYPE_NAME("arm1176"); | ||
45 | -- | 60 | -- |
46 | 2.31.1 | 61 | 2.41.0 |
47 | 62 | ||
48 | 63 | diff view generated by jsdifflib |
1 | From: Peter Delevoryas <pdel@fb.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This adds a new machine type "fuji-bmc" based on the following device tree: | 3 | We want to derivate the big AspeedSoCState object in some more |
4 | 4 | SoC-specific ones. Since the object size will vary, allocate it | |
5 | https://github.com/torvalds/linux/blob/40cb6373b46/arch/arm/boot/dts/aspeed-bmc-facebook-fuji.dts | 5 | dynamically. |
6 | 6 | ||
7 | Most of the i2c devices are not there, they're added here: | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
8 | 8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | |
9 | https://github.com/facebook/openbmc/blob/fb2ed12002fb/meta-facebook/meta-fuji/recipes-utils/openbmc-utils/files/setup_i2c.sh | ||
10 | |||
11 | I tested this by building a Fuji image from Facebook's OpenBMC repo, | ||
12 | booting, and ssh'ing from host-to-guest. | ||
13 | |||
14 | Signed-off-by: Peter Delevoryas <pdel@fb.com> | ||
15 | Reviewed-by: Joel Stanley <joel@jms.id.au> | ||
16 | Message-Id: <20210906133124.3674661-1-pdel@fb.com> | ||
17 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
18 | --- | 10 | --- |
19 | hw/arm/aspeed.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ | 11 | hw/arm/aspeed.c | 101 +++++++++++++++++++++++++----------------------- |
20 | 1 file changed, 113 insertions(+) | 12 | 1 file changed, 52 insertions(+), 49 deletions(-) |
21 | 13 | ||
22 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 14 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c |
23 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/hw/arm/aspeed.c | 16 | --- a/hw/arm/aspeed.c |
25 | +++ b/hw/arm/aspeed.c | 17 | +++ b/hw/arm/aspeed.c |
26 | @@ -XXX,XX +XXX,XX @@ struct AspeedMachineState { | 18 | @@ -XXX,XX +XXX,XX @@ struct AspeedMachineState { |
27 | #define RAINIER_BMC_HW_STRAP1 0x00000000 | 19 | MachineState parent_obj; |
28 | #define RAINIER_BMC_HW_STRAP2 0x00000000 | 20 | /* Public */ |
29 | 21 | ||
30 | +/* Fuji hardware value */ | 22 | - AspeedSoCState soc; |
31 | +#define FUJI_BMC_HW_STRAP1 0x00000000 | 23 | + AspeedSoCState *soc; |
32 | +#define FUJI_BMC_HW_STRAP2 0x00000000 | 24 | MemoryRegion boot_rom; |
33 | + | 25 | bool mmio_exec; |
34 | /* | 26 | uint32_t uart_chosen; |
35 | * The max ram region is for firmwares that scan the address space | 27 | @@ -XXX,XX +XXX,XX @@ static void write_boot_rom(BlockBackend *blk, hwaddr addr, size_t rom_size, |
36 | * with load/store to guess how much RAM the SoC has. | 28 | static void aspeed_install_boot_rom(AspeedMachineState *bmc, BlockBackend *blk, |
37 | @@ -XXX,XX +XXX,XX @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) | 29 | uint64_t rom_size) |
38 | aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB); | 30 | { |
31 | - AspeedSoCState *soc = &bmc->soc; | ||
32 | + AspeedSoCState *soc = bmc->soc; | ||
33 | |||
34 | memory_region_init_rom(&bmc->boot_rom, NULL, "aspeed.boot_rom", rom_size, | ||
35 | &error_abort); | ||
36 | @@ -XXX,XX +XXX,XX @@ static void sdhci_attach_drive(SDHCIState *sdhci, DriveInfo *dinfo) | ||
37 | static void connect_serial_hds_to_uarts(AspeedMachineState *bmc) | ||
38 | { | ||
39 | AspeedMachineClass *amc = ASPEED_MACHINE_GET_CLASS(bmc); | ||
40 | - AspeedSoCState *s = &bmc->soc; | ||
41 | + AspeedSoCState *s = bmc->soc; | ||
42 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
43 | int uart_chosen = bmc->uart_chosen ? bmc->uart_chosen : amc->uart_default; | ||
44 | |||
45 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine) | ||
46 | int i; | ||
47 | NICInfo *nd = &nd_table[0]; | ||
48 | |||
49 | - object_initialize_child(OBJECT(machine), "soc", &bmc->soc, amc->soc_name); | ||
50 | - | ||
51 | - sc = ASPEED_SOC_GET_CLASS(&bmc->soc); | ||
52 | + bmc->soc = ASPEED_SOC(object_new(amc->soc_name)); | ||
53 | + object_property_add_child(OBJECT(machine), "soc", OBJECT(bmc->soc)); | ||
54 | + object_unref(OBJECT(bmc->soc)); | ||
55 | + sc = ASPEED_SOC_GET_CLASS(bmc->soc); | ||
56 | |||
57 | /* | ||
58 | * This will error out if the RAM size is not supported by the | ||
59 | * memory controller of the SoC. | ||
60 | */ | ||
61 | - object_property_set_uint(OBJECT(&bmc->soc), "ram-size", machine->ram_size, | ||
62 | + object_property_set_uint(OBJECT(bmc->soc), "ram-size", machine->ram_size, | ||
63 | &error_fatal); | ||
64 | |||
65 | for (i = 0; i < sc->macs_num; i++) { | ||
66 | if ((amc->macs_mask & (1 << i)) && nd->used) { | ||
67 | qemu_check_nic_model(nd, TYPE_FTGMAC100); | ||
68 | - qdev_set_nic_properties(DEVICE(&bmc->soc.ftgmac100[i]), nd); | ||
69 | + qdev_set_nic_properties(DEVICE(&bmc->soc->ftgmac100[i]), nd); | ||
70 | nd++; | ||
71 | } | ||
72 | } | ||
73 | |||
74 | - object_property_set_int(OBJECT(&bmc->soc), "hw-strap1", amc->hw_strap1, | ||
75 | + object_property_set_int(OBJECT(bmc->soc), "hw-strap1", amc->hw_strap1, | ||
76 | &error_abort); | ||
77 | - object_property_set_int(OBJECT(&bmc->soc), "hw-strap2", amc->hw_strap2, | ||
78 | + object_property_set_int(OBJECT(bmc->soc), "hw-strap2", amc->hw_strap2, | ||
79 | &error_abort); | ||
80 | - object_property_set_link(OBJECT(&bmc->soc), "memory", | ||
81 | + object_property_set_link(OBJECT(bmc->soc), "memory", | ||
82 | OBJECT(get_system_memory()), &error_abort); | ||
83 | - object_property_set_link(OBJECT(&bmc->soc), "dram", | ||
84 | + object_property_set_link(OBJECT(bmc->soc), "dram", | ||
85 | OBJECT(machine->ram), &error_abort); | ||
86 | if (machine->kernel_filename) { | ||
87 | /* | ||
88 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine) | ||
89 | * that runs to unlock the SCU. In this case set the default to | ||
90 | * be unlocked as the kernel expects | ||
91 | */ | ||
92 | - object_property_set_int(OBJECT(&bmc->soc), "hw-prot-key", | ||
93 | + object_property_set_int(OBJECT(bmc->soc), "hw-prot-key", | ||
94 | ASPEED_SCU_PROT_KEY, &error_abort); | ||
95 | } | ||
96 | connect_serial_hds_to_uarts(bmc); | ||
97 | - qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort); | ||
98 | + qdev_realize(DEVICE(bmc->soc), NULL, &error_abort); | ||
99 | |||
100 | if (defaults_enabled()) { | ||
101 | - aspeed_board_init_flashes(&bmc->soc.fmc, | ||
102 | + aspeed_board_init_flashes(&bmc->soc->fmc, | ||
103 | bmc->fmc_model ? bmc->fmc_model : amc->fmc_model, | ||
104 | amc->num_cs, 0); | ||
105 | - aspeed_board_init_flashes(&bmc->soc.spi[0], | ||
106 | + aspeed_board_init_flashes(&bmc->soc->spi[0], | ||
107 | bmc->spi_model ? bmc->spi_model : amc->spi_model, | ||
108 | 1, amc->num_cs); | ||
109 | } | ||
110 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine) | ||
111 | amc->i2c_init(bmc); | ||
112 | } | ||
113 | |||
114 | - for (i = 0; i < bmc->soc.sdhci.num_slots; i++) { | ||
115 | - sdhci_attach_drive(&bmc->soc.sdhci.slots[i], | ||
116 | + for (i = 0; i < bmc->soc->sdhci.num_slots; i++) { | ||
117 | + sdhci_attach_drive(&bmc->soc->sdhci.slots[i], | ||
118 | drive_get(IF_SD, 0, i)); | ||
119 | } | ||
120 | |||
121 | - if (bmc->soc.emmc.num_slots) { | ||
122 | - sdhci_attach_drive(&bmc->soc.emmc.slots[0], | ||
123 | - drive_get(IF_SD, 0, bmc->soc.sdhci.num_slots)); | ||
124 | + if (bmc->soc->emmc.num_slots) { | ||
125 | + sdhci_attach_drive(&bmc->soc->emmc.slots[0], | ||
126 | + drive_get(IF_SD, 0, bmc->soc->sdhci.num_slots)); | ||
127 | } | ||
128 | |||
129 | if (!bmc->mmio_exec) { | ||
130 | - DeviceState *dev = ssi_get_cs(bmc->soc.fmc.spi, 0); | ||
131 | + DeviceState *dev = ssi_get_cs(bmc->soc->fmc.spi, 0); | ||
132 | BlockBackend *fmc0 = dev ? m25p80_get_blk(dev) : NULL; | ||
133 | |||
134 | if (fmc0) { | ||
135 | - uint64_t rom_size = memory_region_size(&bmc->soc.spi_boot); | ||
136 | + uint64_t rom_size = memory_region_size(&bmc->soc->spi_boot); | ||
137 | aspeed_install_boot_rom(bmc, fmc0, rom_size); | ||
138 | } | ||
139 | } | ||
140 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine) | ||
141 | |||
142 | static void palmetto_bmc_i2c_init(AspeedMachineState *bmc) | ||
143 | { | ||
144 | - AspeedSoCState *soc = &bmc->soc; | ||
145 | + AspeedSoCState *soc = bmc->soc; | ||
146 | DeviceState *dev; | ||
147 | uint8_t *eeprom_buf = g_malloc0(32 * 1024); | ||
148 | |||
149 | @@ -XXX,XX +XXX,XX @@ static void palmetto_bmc_i2c_init(AspeedMachineState *bmc) | ||
150 | |||
151 | static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc) | ||
152 | { | ||
153 | - AspeedSoCState *soc = &bmc->soc; | ||
154 | + AspeedSoCState *soc = bmc->soc; | ||
155 | |||
156 | /* | ||
157 | * The quanta-q71l platform expects tmp75s which are compatible with | ||
158 | @@ -XXX,XX +XXX,XX @@ static void quanta_q71l_bmc_i2c_init(AspeedMachineState *bmc) | ||
159 | |||
160 | static void ast2500_evb_i2c_init(AspeedMachineState *bmc) | ||
161 | { | ||
162 | - AspeedSoCState *soc = &bmc->soc; | ||
163 | + AspeedSoCState *soc = bmc->soc; | ||
164 | uint8_t *eeprom_buf = g_malloc0(8 * 1024); | ||
165 | |||
166 | smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 3), 0x50, | ||
167 | @@ -XXX,XX +XXX,XX @@ static void ast2500_evb_i2c_init(AspeedMachineState *bmc) | ||
168 | |||
169 | static void ast2600_evb_i2c_init(AspeedMachineState *bmc) | ||
170 | { | ||
171 | - AspeedSoCState *soc = &bmc->soc; | ||
172 | + AspeedSoCState *soc = bmc->soc; | ||
173 | uint8_t *eeprom_buf = g_malloc0(8 * 1024); | ||
174 | |||
175 | smbus_eeprom_init_one(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, | ||
176 | @@ -XXX,XX +XXX,XX @@ static void ast2600_evb_i2c_init(AspeedMachineState *bmc) | ||
177 | |||
178 | static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc) | ||
179 | { | ||
180 | - AspeedSoCState *soc = &bmc->soc; | ||
181 | + AspeedSoCState *soc = bmc->soc; | ||
182 | |||
183 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x51, 128 * KiB); | ||
184 | at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 128 * KiB, | ||
185 | @@ -XXX,XX +XXX,XX @@ static void yosemitev2_bmc_i2c_init(AspeedMachineState *bmc) | ||
186 | |||
187 | static void romulus_bmc_i2c_init(AspeedMachineState *bmc) | ||
188 | { | ||
189 | - AspeedSoCState *soc = &bmc->soc; | ||
190 | + AspeedSoCState *soc = bmc->soc; | ||
191 | |||
192 | /* The romulus board expects Epson RX8900 I2C RTC but a ds1338 is | ||
193 | * good enough */ | ||
194 | @@ -XXX,XX +XXX,XX @@ static void romulus_bmc_i2c_init(AspeedMachineState *bmc) | ||
195 | |||
196 | static void tiogapass_bmc_i2c_init(AspeedMachineState *bmc) | ||
197 | { | ||
198 | - AspeedSoCState *soc = &bmc->soc; | ||
199 | + AspeedSoCState *soc = bmc->soc; | ||
200 | |||
201 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 4), 0x54, 128 * KiB); | ||
202 | at24c_eeprom_init_rom(aspeed_i2c_get_bus(&soc->i2c, 6), 0x54, 128 * KiB, | ||
203 | @@ -XXX,XX +XXX,XX @@ static void create_pca9552(AspeedSoCState *soc, int bus_id, int addr) | ||
204 | |||
205 | static void sonorapass_bmc_i2c_init(AspeedMachineState *bmc) | ||
206 | { | ||
207 | - AspeedSoCState *soc = &bmc->soc; | ||
208 | + AspeedSoCState *soc = bmc->soc; | ||
209 | |||
210 | /* bus 2 : */ | ||
211 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 2), "tmp105", 0x48); | ||
212 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc) | ||
213 | {14, LED_COLOR_GREEN, "front-power-3", GPIO_POLARITY_ACTIVE_LOW}, | ||
214 | {15, LED_COLOR_GREEN, "front-id-5", GPIO_POLARITY_ACTIVE_LOW}, | ||
215 | }; | ||
216 | - AspeedSoCState *soc = &bmc->soc; | ||
217 | + AspeedSoCState *soc = bmc->soc; | ||
218 | uint8_t *eeprom_buf = g_malloc0(8 * 1024); | ||
219 | DeviceState *dev; | ||
220 | LEDState *led; | ||
221 | @@ -XXX,XX +XXX,XX @@ static void witherspoon_bmc_i2c_init(AspeedMachineState *bmc) | ||
222 | |||
223 | static void g220a_bmc_i2c_init(AspeedMachineState *bmc) | ||
224 | { | ||
225 | - AspeedSoCState *soc = &bmc->soc; | ||
226 | + AspeedSoCState *soc = bmc->soc; | ||
227 | DeviceState *dev; | ||
228 | |||
229 | dev = DEVICE(i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 3), | ||
230 | @@ -XXX,XX +XXX,XX @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc) | ||
231 | |||
232 | static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc) | ||
233 | { | ||
234 | - AspeedSoCState *soc = &bmc->soc; | ||
235 | + AspeedSoCState *soc = bmc->soc; | ||
236 | I2CSlave *i2c_mux; | ||
237 | |||
238 | /* The at24c256 */ | ||
239 | @@ -XXX,XX +XXX,XX @@ static void fp5280g2_bmc_i2c_init(AspeedMachineState *bmc) | ||
240 | |||
241 | static void rainier_bmc_i2c_init(AspeedMachineState *bmc) | ||
242 | { | ||
243 | - AspeedSoCState *soc = &bmc->soc; | ||
244 | + AspeedSoCState *soc = bmc->soc; | ||
245 | I2CSlave *i2c_mux; | ||
246 | |||
247 | at24c_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB); | ||
248 | @@ -XXX,XX +XXX,XX @@ static void get_pca9548_channels(I2CBus *bus, uint8_t mux_addr, | ||
249 | |||
250 | static void fuji_bmc_i2c_init(AspeedMachineState *bmc) | ||
251 | { | ||
252 | - AspeedSoCState *soc = &bmc->soc; | ||
253 | + AspeedSoCState *soc = bmc->soc; | ||
254 | I2CBus *i2c[144] = {}; | ||
255 | |||
256 | for (int i = 0; i < 16; i++) { | ||
257 | @@ -XXX,XX +XXX,XX @@ static void fuji_bmc_i2c_init(AspeedMachineState *bmc) | ||
258 | |||
259 | static void bletchley_bmc_i2c_init(AspeedMachineState *bmc) | ||
260 | { | ||
261 | - AspeedSoCState *soc = &bmc->soc; | ||
262 | + AspeedSoCState *soc = bmc->soc; | ||
263 | I2CBus *i2c[13] = {}; | ||
264 | for (int i = 0; i < 13; i++) { | ||
265 | if ((i == 8) || (i == 11)) { | ||
266 | @@ -XXX,XX +XXX,XX @@ static void bletchley_bmc_i2c_init(AspeedMachineState *bmc) | ||
267 | |||
268 | static void fby35_i2c_init(AspeedMachineState *bmc) | ||
269 | { | ||
270 | - AspeedSoCState *soc = &bmc->soc; | ||
271 | + AspeedSoCState *soc = bmc->soc; | ||
272 | I2CBus *i2c[16]; | ||
273 | |||
274 | for (int i = 0; i < 16; i++) { | ||
275 | @@ -XXX,XX +XXX,XX @@ static void fby35_i2c_init(AspeedMachineState *bmc) | ||
276 | |||
277 | static void qcom_dc_scm_bmc_i2c_init(AspeedMachineState *bmc) | ||
278 | { | ||
279 | - AspeedSoCState *soc = &bmc->soc; | ||
280 | + AspeedSoCState *soc = bmc->soc; | ||
281 | |||
282 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 15), "tmp105", 0x4d); | ||
39 | } | 283 | } |
40 | 284 | ||
41 | +static void get_pca9548_channels(I2CBus *bus, uint8_t mux_addr, | 285 | static void qcom_dc_scm_firework_i2c_init(AspeedMachineState *bmc) |
42 | + I2CBus **channels) | 286 | { |
43 | +{ | 287 | - AspeedSoCState *soc = &bmc->soc; |
44 | + I2CSlave *mux = i2c_slave_create_simple(bus, "pca9548", mux_addr); | 288 | + AspeedSoCState *soc = bmc->soc; |
45 | + for (int i = 0; i < 8; i++) { | 289 | I2CSlave *therm_mux, *cpuvr_mux; |
46 | + channels[i] = pca954x_i2c_get_bus(mux, i); | 290 | |
47 | + } | 291 | /* Create the generic DC-SCM hardware */ |
48 | +} | 292 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_bletchley_class_init(ObjectClass *oc, void *data) |
49 | + | 293 | static void fby35_reset(MachineState *state, ShutdownCause reason) |
50 | +#define TYPE_LM75 TYPE_TMP105 | 294 | { |
51 | +#define TYPE_TMP75 TYPE_TMP105 | 295 | AspeedMachineState *bmc = ASPEED_MACHINE(state); |
52 | +#define TYPE_TMP422 "tmp422" | 296 | - AspeedGPIOState *gpio = &bmc->soc.gpio; |
53 | + | 297 | + AspeedGPIOState *gpio = &bmc->soc->gpio; |
54 | +static void fuji_bmc_i2c_init(AspeedMachineState *bmc) | 298 | |
55 | +{ | 299 | qemu_devices_reset(reason); |
56 | + AspeedSoCState *soc = &bmc->soc; | 300 | |
57 | + I2CBus *i2c[144] = {}; | 301 | @@ -XXX,XX +XXX,XX @@ static void aspeed_minibmc_machine_init(MachineState *machine) |
58 | + | 302 | sysclk = clock_new(OBJECT(machine), "SYSCLK"); |
59 | + for (int i = 0; i < 16; i++) { | 303 | clock_set_hz(sysclk, SYSCLK_FRQ); |
60 | + i2c[i] = aspeed_i2c_get_bus(&soc->i2c, i); | 304 | |
61 | + } | 305 | - object_initialize_child(OBJECT(machine), "soc", &bmc->soc, amc->soc_name); |
62 | + I2CBus *i2c180 = i2c[2]; | 306 | - qdev_connect_clock_in(DEVICE(&bmc->soc), "sysclk", sysclk); |
63 | + I2CBus *i2c480 = i2c[8]; | 307 | + bmc->soc = ASPEED_SOC(object_new(amc->soc_name)); |
64 | + I2CBus *i2c600 = i2c[11]; | 308 | + object_property_add_child(OBJECT(machine), "soc", OBJECT(bmc->soc)); |
65 | + | 309 | + object_unref(OBJECT(bmc->soc)); |
66 | + get_pca9548_channels(i2c180, 0x70, &i2c[16]); | 310 | + qdev_connect_clock_in(DEVICE(bmc->soc), "sysclk", sysclk); |
67 | + get_pca9548_channels(i2c480, 0x70, &i2c[24]); | 311 | |
68 | + /* NOTE: The device tree skips [32, 40) in the alias numbering */ | 312 | - object_property_set_link(OBJECT(&bmc->soc), "memory", |
69 | + get_pca9548_channels(i2c600, 0x77, &i2c[40]); | 313 | + object_property_set_link(OBJECT(bmc->soc), "memory", |
70 | + get_pca9548_channels(i2c[24], 0x71, &i2c[48]); | 314 | OBJECT(get_system_memory()), &error_abort); |
71 | + get_pca9548_channels(i2c[25], 0x72, &i2c[56]); | 315 | connect_serial_hds_to_uarts(bmc); |
72 | + get_pca9548_channels(i2c[26], 0x76, &i2c[64]); | 316 | - qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort); |
73 | + get_pca9548_channels(i2c[27], 0x76, &i2c[72]); | 317 | + qdev_realize(DEVICE(bmc->soc), NULL, &error_abort); |
74 | + for (int i = 0; i < 8; i++) { | 318 | |
75 | + get_pca9548_channels(i2c[40 + i], 0x76, &i2c[80 + i * 8]); | 319 | - aspeed_board_init_flashes(&bmc->soc.fmc, |
76 | + } | 320 | + aspeed_board_init_flashes(&bmc->soc->fmc, |
77 | + | 321 | bmc->fmc_model ? bmc->fmc_model : amc->fmc_model, |
78 | + i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4c); | 322 | amc->num_cs, |
79 | + i2c_slave_create_simple(i2c[17], TYPE_LM75, 0x4d); | 323 | 0); |
80 | + | 324 | |
81 | + aspeed_eeprom_init(i2c[19], 0x52, 64 * KiB); | 325 | - aspeed_board_init_flashes(&bmc->soc.spi[0], |
82 | + aspeed_eeprom_init(i2c[20], 0x50, 2 * KiB); | 326 | + aspeed_board_init_flashes(&bmc->soc->spi[0], |
83 | + aspeed_eeprom_init(i2c[22], 0x52, 2 * KiB); | 327 | bmc->spi_model ? bmc->spi_model : amc->spi_model, |
84 | + | 328 | amc->num_cs, amc->num_cs); |
85 | + i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x48); | 329 | |
86 | + i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x49); | 330 | - aspeed_board_init_flashes(&bmc->soc.spi[1], |
87 | + i2c_slave_create_simple(i2c[3], TYPE_LM75, 0x4a); | 331 | + aspeed_board_init_flashes(&bmc->soc->spi[1], |
88 | + i2c_slave_create_simple(i2c[3], TYPE_TMP422, 0x4c); | 332 | bmc->spi_model ? bmc->spi_model : amc->spi_model, |
89 | + | 333 | amc->num_cs, (amc->num_cs * 2)); |
90 | + aspeed_eeprom_init(i2c[8], 0x51, 64 * KiB); | 334 | |
91 | + i2c_slave_create_simple(i2c[8], TYPE_LM75, 0x4a); | 335 | @@ -XXX,XX +XXX,XX @@ static void aspeed_minibmc_machine_init(MachineState *machine) |
92 | + | 336 | |
93 | + i2c_slave_create_simple(i2c[50], TYPE_LM75, 0x4c); | 337 | static void ast1030_evb_i2c_init(AspeedMachineState *bmc) |
94 | + aspeed_eeprom_init(i2c[50], 0x52, 64 * KiB); | 338 | { |
95 | + i2c_slave_create_simple(i2c[51], TYPE_TMP75, 0x48); | 339 | - AspeedSoCState *soc = &bmc->soc; |
96 | + i2c_slave_create_simple(i2c[52], TYPE_TMP75, 0x49); | 340 | + AspeedSoCState *soc = bmc->soc; |
97 | + | 341 | |
98 | + i2c_slave_create_simple(i2c[59], TYPE_TMP75, 0x48); | 342 | /* U10 24C08 connects to SDA/SCL Group 1 by default */ |
99 | + i2c_slave_create_simple(i2c[60], TYPE_TMP75, 0x49); | 343 | uint8_t *eeprom_buf = g_malloc0(32 * 1024); |
100 | + | ||
101 | + aspeed_eeprom_init(i2c[65], 0x53, 64 * KiB); | ||
102 | + i2c_slave_create_simple(i2c[66], TYPE_TMP75, 0x49); | ||
103 | + i2c_slave_create_simple(i2c[66], TYPE_TMP75, 0x48); | ||
104 | + aspeed_eeprom_init(i2c[68], 0x52, 64 * KiB); | ||
105 | + aspeed_eeprom_init(i2c[69], 0x52, 64 * KiB); | ||
106 | + aspeed_eeprom_init(i2c[70], 0x52, 64 * KiB); | ||
107 | + aspeed_eeprom_init(i2c[71], 0x52, 64 * KiB); | ||
108 | + | ||
109 | + aspeed_eeprom_init(i2c[73], 0x53, 64 * KiB); | ||
110 | + i2c_slave_create_simple(i2c[74], TYPE_TMP75, 0x49); | ||
111 | + i2c_slave_create_simple(i2c[74], TYPE_TMP75, 0x48); | ||
112 | + aspeed_eeprom_init(i2c[76], 0x52, 64 * KiB); | ||
113 | + aspeed_eeprom_init(i2c[77], 0x52, 64 * KiB); | ||
114 | + aspeed_eeprom_init(i2c[78], 0x52, 64 * KiB); | ||
115 | + aspeed_eeprom_init(i2c[79], 0x52, 64 * KiB); | ||
116 | + aspeed_eeprom_init(i2c[28], 0x50, 2 * KiB); | ||
117 | + | ||
118 | + for (int i = 0; i < 8; i++) { | ||
119 | + aspeed_eeprom_init(i2c[81 + i * 8], 0x56, 64 * KiB); | ||
120 | + i2c_slave_create_simple(i2c[82 + i * 8], TYPE_TMP75, 0x48); | ||
121 | + i2c_slave_create_simple(i2c[83 + i * 8], TYPE_TMP75, 0x4b); | ||
122 | + i2c_slave_create_simple(i2c[84 + i * 8], TYPE_TMP75, 0x4a); | ||
123 | + } | ||
124 | +} | ||
125 | + | ||
126 | static bool aspeed_get_mmio_exec(Object *obj, Error **errp) | ||
127 | { | ||
128 | return ASPEED_MACHINE(obj)->mmio_exec; | ||
129 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_rainier_class_init(ObjectClass *oc, void *data) | ||
130 | aspeed_soc_num_cpus(amc->soc_name); | ||
131 | }; | ||
132 | |||
133 | +static void aspeed_machine_fuji_class_init(ObjectClass *oc, void *data) | ||
134 | +{ | ||
135 | + MachineClass *mc = MACHINE_CLASS(oc); | ||
136 | + AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
137 | + | ||
138 | + mc->desc = "Facebook Fuji BMC (Cortex-A7)"; | ||
139 | + amc->soc_name = "ast2600-a3"; | ||
140 | + amc->hw_strap1 = FUJI_BMC_HW_STRAP1; | ||
141 | + amc->hw_strap2 = FUJI_BMC_HW_STRAP2; | ||
142 | + amc->fmc_model = "mx66l1g45g"; | ||
143 | + amc->spi_model = "mx66l1g45g"; | ||
144 | + amc->num_cs = 2; | ||
145 | + amc->macs_mask = ASPEED_MAC3_ON; | ||
146 | + amc->i2c_init = fuji_bmc_i2c_init; | ||
147 | + amc->uart_default = ASPEED_DEV_UART1; | ||
148 | + mc->default_ram_size = 2 * GiB; | ||
149 | + mc->default_cpus = mc->min_cpus = mc->max_cpus = | ||
150 | + aspeed_soc_num_cpus(amc->soc_name); | ||
151 | +}; | ||
152 | + | ||
153 | static const TypeInfo aspeed_machine_types[] = { | ||
154 | { | ||
155 | .name = MACHINE_TYPE_NAME("palmetto-bmc"), | ||
156 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_machine_types[] = { | ||
157 | .name = MACHINE_TYPE_NAME("rainier-bmc"), | ||
158 | .parent = TYPE_ASPEED_MACHINE, | ||
159 | .class_init = aspeed_machine_rainier_class_init, | ||
160 | + }, { | ||
161 | + .name = MACHINE_TYPE_NAME("fuji-bmc"), | ||
162 | + .parent = TYPE_ASPEED_MACHINE, | ||
163 | + .class_init = aspeed_machine_fuji_class_init, | ||
164 | }, { | ||
165 | .name = TYPE_ASPEED_MACHINE, | ||
166 | .parent = TYPE_MACHINE, | ||
167 | -- | 344 | -- |
168 | 2.31.1 | 345 | 2.41.0 |
169 | 346 | ||
170 | 347 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There are two GPIO controllers in the ast2600; one is 3.3V and the other | 3 | TYPE_ASPEED10X0_SOC inherits from TYPE_ASPEED_SOC. |
4 | is 1.8V. | 4 | In few commits we'll add more fields, but to keep |
5 | review process simple, don't add any yet. | ||
5 | 6 | ||
6 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
7 | Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
9 | Message-Id: <20210713065854.134634-4-joel@jms.id.au> | ||
10 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
11 | --- | 10 | --- |
12 | hw/gpio/aspeed_gpio.c | 26 +++++++++++++------------- | 11 | include/hw/arm/aspeed_soc.h | 7 +++++++ |
13 | 1 file changed, 13 insertions(+), 13 deletions(-) | 12 | hw/arm/aspeed_ast10x0.c | 26 +++++++++++++------------- |
13 | 2 files changed, 20 insertions(+), 13 deletions(-) | ||
14 | 14 | ||
15 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c | 15 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
16 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/gpio/aspeed_gpio.c | 17 | --- a/include/hw/arm/aspeed_soc.h |
18 | +++ b/hw/gpio/aspeed_gpio.c | 18 | +++ b/include/hw/arm/aspeed_soc.h |
19 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ struct AspeedSoCState { |
20 | #define GPIO_YZAAAB_DIRECTION (0x1E4 >> 2) | 20 | #define TYPE_ASPEED_SOC "aspeed-soc" |
21 | #define GPIO_AC_DATA_VALUE (0x1E8 >> 2) | 21 | OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC) |
22 | #define GPIO_AC_DIRECTION (0x1EC >> 2) | 22 | |
23 | -#define GPIO_3_6V_MEM_SIZE 0x1F0 | 23 | +struct Aspeed10x0SoCState { |
24 | -#define GPIO_3_6V_REG_ARRAY_SIZE (GPIO_3_6V_MEM_SIZE >> 2) | 24 | + AspeedSoCState parent; |
25 | +#define GPIO_3_3V_MEM_SIZE 0x1F0 | 25 | +}; |
26 | +#define GPIO_3_3V_REG_ARRAY_SIZE (GPIO_3_3V_MEM_SIZE >> 2) | 26 | + |
27 | 27 | +#define TYPE_ASPEED10X0_SOC "aspeed10x0-soc" | |
28 | /* AST2600 only - 1.8V gpios */ | 28 | +OBJECT_DECLARE_SIMPLE_TYPE(Aspeed10x0SoCState, ASPEED10X0_SOC) |
29 | /* | 29 | + |
30 | - * The AST2600 two copies of the GPIO controller: the same 3.6V gpios as the | 30 | struct AspeedSoCClass { |
31 | + * The AST2600 two copies of the GPIO controller: the same 3.3V gpios as the | 31 | DeviceClass parent_class; |
32 | * AST2400 (memory offsets 0x0-0x198) and a second controller with 1.8V gpios | 32 | |
33 | * (memory offsets 0x800-0x9D4). | 33 | diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c |
34 | */ | 34 | index XXXXXXX..XXXXXXX 100644 |
35 | @@ -XXX,XX +XXX,XX @@ static uint32_t update_value_control_source(GPIOSets *regs, uint32_t old_value, | 35 | --- a/hw/arm/aspeed_ast10x0.c |
36 | return new_value; | 36 | +++ b/hw/arm/aspeed_ast10x0.c |
37 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_class_init(ObjectClass *klass, void *data) | ||
38 | sc->get_irq = aspeed_soc_ast1030_get_irq; | ||
37 | } | 39 | } |
38 | 40 | ||
39 | -static const AspeedGPIOReg aspeed_3_6v_gpios[GPIO_3_6V_REG_ARRAY_SIZE] = { | 41 | -static const TypeInfo aspeed_soc_ast1030_type_info = { |
40 | +static const AspeedGPIOReg aspeed_3_3v_gpios[GPIO_3_3V_REG_ARRAY_SIZE] = { | 42 | - .name = "ast1030-a1", |
41 | /* Set ABCD */ | 43 | - .parent = TYPE_ASPEED_SOC, |
42 | [GPIO_ABCD_DATA_VALUE] = { 0, gpio_reg_data_value }, | 44 | - .instance_size = sizeof(AspeedSoCState), |
43 | [GPIO_ABCD_DIRECTION] = { 0, gpio_reg_direction }, | 45 | - .instance_init = aspeed_soc_ast1030_init, |
44 | @@ -XXX,XX +XXX,XX @@ static const GPIOSetProperties ast2500_set_props[] = { | 46 | - .class_init = aspeed_soc_ast1030_class_init, |
45 | [7] = {0x000000ff, 0x000000ff, {"AC"} }, | 47 | - .class_size = sizeof(AspeedSoCClass), |
48 | +static const TypeInfo aspeed_soc_ast10x0_types[] = { | ||
49 | + { | ||
50 | + .name = TYPE_ASPEED10X0_SOC, | ||
51 | + .parent = TYPE_ASPEED_SOC, | ||
52 | + .instance_size = sizeof(Aspeed10x0SoCState), | ||
53 | + .abstract = true, | ||
54 | + }, { | ||
55 | + .name = "ast1030-a1", | ||
56 | + .parent = TYPE_ASPEED10X0_SOC, | ||
57 | + .instance_init = aspeed_soc_ast1030_init, | ||
58 | + .class_init = aspeed_soc_ast1030_class_init, | ||
59 | + }, | ||
46 | }; | 60 | }; |
47 | 61 | ||
48 | -static GPIOSetProperties ast2600_3_6v_set_props[] = { | 62 | -static void aspeed_soc_register_types(void) |
49 | +static GPIOSetProperties ast2600_3_3v_set_props[] = { | 63 | -{ |
50 | [0] = {0xffffffff, 0xffffffff, {"A", "B", "C", "D"} }, | 64 | - type_register_static(&aspeed_soc_ast1030_type_info); |
51 | [1] = {0xffffffff, 0xffffffff, {"E", "F", "G", "H"} }, | 65 | -} |
52 | [2] = {0xffffffff, 0xffffffff, {"I", "J", "K", "L"} }, | 66 | - |
53 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_ast2400_class_init(ObjectClass *klass, void *data) | 67 | -type_init(aspeed_soc_register_types) |
54 | agc->nr_gpio_pins = 216; | 68 | +DEFINE_TYPES(aspeed_soc_ast10x0_types) |
55 | agc->nr_gpio_sets = 7; | ||
56 | agc->gap = 196; | ||
57 | - agc->reg_table = aspeed_3_6v_gpios; | ||
58 | + agc->reg_table = aspeed_3_3v_gpios; | ||
59 | } | ||
60 | |||
61 | static void aspeed_gpio_2500_class_init(ObjectClass *klass, void *data) | ||
62 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_2500_class_init(ObjectClass *klass, void *data) | ||
63 | agc->nr_gpio_pins = 228; | ||
64 | agc->nr_gpio_sets = 8; | ||
65 | agc->gap = 220; | ||
66 | - agc->reg_table = aspeed_3_6v_gpios; | ||
67 | + agc->reg_table = aspeed_3_3v_gpios; | ||
68 | } | ||
69 | |||
70 | -static void aspeed_gpio_ast2600_3_6v_class_init(ObjectClass *klass, void *data) | ||
71 | +static void aspeed_gpio_ast2600_3_3v_class_init(ObjectClass *klass, void *data) | ||
72 | { | ||
73 | AspeedGPIOClass *agc = ASPEED_GPIO_CLASS(klass); | ||
74 | |||
75 | - agc->props = ast2600_3_6v_set_props; | ||
76 | + agc->props = ast2600_3_3v_set_props; | ||
77 | agc->nr_gpio_pins = 208; | ||
78 | agc->nr_gpio_sets = 7; | ||
79 | - agc->reg_table = aspeed_3_6v_gpios; | ||
80 | + agc->reg_table = aspeed_3_3v_gpios; | ||
81 | } | ||
82 | |||
83 | static void aspeed_gpio_ast2600_1_8v_class_init(ObjectClass *klass, void *data) | ||
84 | @@ -XXX,XX +XXX,XX @@ static const TypeInfo aspeed_gpio_ast2500_info = { | ||
85 | .instance_init = aspeed_gpio_init, | ||
86 | }; | ||
87 | |||
88 | -static const TypeInfo aspeed_gpio_ast2600_3_6v_info = { | ||
89 | +static const TypeInfo aspeed_gpio_ast2600_3_3v_info = { | ||
90 | .name = TYPE_ASPEED_GPIO "-ast2600", | ||
91 | .parent = TYPE_ASPEED_GPIO, | ||
92 | - .class_init = aspeed_gpio_ast2600_3_6v_class_init, | ||
93 | + .class_init = aspeed_gpio_ast2600_3_3v_class_init, | ||
94 | .instance_init = aspeed_gpio_init, | ||
95 | }; | ||
96 | |||
97 | @@ -XXX,XX +XXX,XX @@ static void aspeed_gpio_register_types(void) | ||
98 | type_register_static(&aspeed_gpio_info); | ||
99 | type_register_static(&aspeed_gpio_ast2400_info); | ||
100 | type_register_static(&aspeed_gpio_ast2500_info); | ||
101 | - type_register_static(&aspeed_gpio_ast2600_3_6v_info); | ||
102 | + type_register_static(&aspeed_gpio_ast2600_3_3v_info); | ||
103 | type_register_static(&aspeed_gpio_ast2600_1_8v_info); | ||
104 | } | ||
105 | |||
106 | -- | 69 | -- |
107 | 2.31.1 | 70 | 2.41.0 |
108 | 71 | ||
109 | 72 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | This is the latest revision of the ASPEED 2600 SoC. As there is no | 3 | TYPE_ASPEED2600_SOC inherits from TYPE_ASPEED_SOC. |
4 | need to model multiple revisions of the same SoC for the moment, | 4 | In few commits we'll add more fields, but to keep |
5 | update the SCU AST2600 to model the A3 revision instead of the A1 and | 5 | review process simple, don't add any yet. |
6 | adapt the AST2600 SoC and machines. | ||
7 | 6 | ||
8 | Reset values are taken from v8 of the datasheet. | 7 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | 8 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | |
10 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
11 | [ clg: - Introduced an Aspeed "ast2600-a3" SoC class | ||
12 | - Commit log update ] | ||
13 | Message-Id: <20210629142336.750058-3-clg@kaod.org> | ||
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 9 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
15 | --- | 10 | --- |
16 | include/hw/misc/aspeed_scu.h | 2 ++ | 11 | include/hw/arm/aspeed_soc.h | 7 +++++++ |
17 | hw/arm/aspeed.c | 6 +++--- | 12 | hw/arm/aspeed_ast2600.c | 26 +++++++++++++------------- |
18 | hw/arm/aspeed_ast2600.c | 6 +++--- | 13 | 2 files changed, 20 insertions(+), 13 deletions(-) |
19 | hw/misc/aspeed_scu.c | 36 +++++++++++++++++++++++++++++------- | ||
20 | 4 files changed, 37 insertions(+), 13 deletions(-) | ||
21 | 14 | ||
22 | diff --git a/include/hw/misc/aspeed_scu.h b/include/hw/misc/aspeed_scu.h | 15 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
23 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
24 | --- a/include/hw/misc/aspeed_scu.h | 17 | --- a/include/hw/arm/aspeed_soc.h |
25 | +++ b/include/hw/misc/aspeed_scu.h | 18 | +++ b/include/hw/arm/aspeed_soc.h |
26 | @@ -XXX,XX +XXX,XX @@ struct AspeedSCUState { | 19 | @@ -XXX,XX +XXX,XX @@ struct AspeedSoCState { |
27 | #define AST2500_A1_SILICON_REV 0x04010303U | 20 | #define TYPE_ASPEED_SOC "aspeed-soc" |
28 | #define AST2600_A0_SILICON_REV 0x05000303U | 21 | OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC) |
29 | #define AST2600_A1_SILICON_REV 0x05010303U | 22 | |
30 | +#define AST2600_A2_SILICON_REV 0x05020303U | 23 | +struct Aspeed2600SoCState { |
31 | +#define AST2600_A3_SILICON_REV 0x05030303U | 24 | + AspeedSoCState parent; |
32 | 25 | +}; | |
33 | #define ASPEED_IS_AST2500(si_rev) ((((si_rev) >> 24) & 0xff) == 0x04) | 26 | + |
34 | 27 | +#define TYPE_ASPEED2600_SOC "aspeed2600-soc" | |
35 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 28 | +OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2600SoCState, ASPEED2600_SOC) |
36 | index XXXXXXX..XXXXXXX 100644 | 29 | + |
37 | --- a/hw/arm/aspeed.c | 30 | struct Aspeed10x0SoCState { |
38 | +++ b/hw/arm/aspeed.c | 31 | AspeedSoCState parent; |
39 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_ast2600_evb_class_init(ObjectClass *oc, void *data) | 32 | }; |
40 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
41 | |||
42 | mc->desc = "Aspeed AST2600 EVB (Cortex-A7)"; | ||
43 | - amc->soc_name = "ast2600-a1"; | ||
44 | + amc->soc_name = "ast2600-a3"; | ||
45 | amc->hw_strap1 = AST2600_EVB_HW_STRAP1; | ||
46 | amc->hw_strap2 = AST2600_EVB_HW_STRAP2; | ||
47 | amc->fmc_model = "w25q512jv"; | ||
48 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_tacoma_class_init(ObjectClass *oc, void *data) | ||
49 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
50 | |||
51 | mc->desc = "OpenPOWER Tacoma BMC (Cortex-A7)"; | ||
52 | - amc->soc_name = "ast2600-a1"; | ||
53 | + amc->soc_name = "ast2600-a3"; | ||
54 | amc->hw_strap1 = TACOMA_BMC_HW_STRAP1; | ||
55 | amc->hw_strap2 = TACOMA_BMC_HW_STRAP2; | ||
56 | amc->fmc_model = "mx66l1g45g"; | ||
57 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_rainier_class_init(ObjectClass *oc, void *data) | ||
58 | AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc); | ||
59 | |||
60 | mc->desc = "IBM Rainier BMC (Cortex-A7)"; | ||
61 | - amc->soc_name = "ast2600-a1"; | ||
62 | + amc->soc_name = "ast2600-a3"; | ||
63 | amc->hw_strap1 = RAINIER_BMC_HW_STRAP1; | ||
64 | amc->hw_strap2 = RAINIER_BMC_HW_STRAP2; | ||
65 | amc->fmc_model = "mx66l1g45g"; | ||
66 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | 33 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c |
67 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
68 | --- a/hw/arm/aspeed_ast2600.c | 35 | --- a/hw/arm/aspeed_ast2600.c |
69 | +++ b/hw/arm/aspeed_ast2600.c | 36 | +++ b/hw/arm/aspeed_ast2600.c |
70 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) | 37 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) |
71 | 38 | sc->get_irq = aspeed_soc_ast2600_get_irq; | |
72 | dc->realize = aspeed_soc_ast2600_realize; | ||
73 | |||
74 | - sc->name = "ast2600-a1"; | ||
75 | + sc->name = "ast2600-a3"; | ||
76 | sc->cpu_type = ARM_CPU_TYPE_NAME("cortex-a7"); | ||
77 | - sc->silicon_rev = AST2600_A1_SILICON_REV; | ||
78 | + sc->silicon_rev = AST2600_A3_SILICON_REV; | ||
79 | sc->sram_size = 0x16400; | ||
80 | sc->spis_num = 2; | ||
81 | sc->ehcis_num = 2; | ||
82 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_class_init(ObjectClass *oc, void *data) | ||
83 | } | 39 | } |
84 | 40 | ||
85 | static const TypeInfo aspeed_soc_ast2600_type_info = { | 41 | -static const TypeInfo aspeed_soc_ast2600_type_info = { |
86 | - .name = "ast2600-a1", | 42 | - .name = "ast2600-a3", |
87 | + .name = "ast2600-a3", | 43 | - .parent = TYPE_ASPEED_SOC, |
88 | .parent = TYPE_ASPEED_SOC, | 44 | - .instance_size = sizeof(AspeedSoCState), |
89 | .instance_size = sizeof(AspeedSoCState), | 45 | - .instance_init = aspeed_soc_ast2600_init, |
90 | .instance_init = aspeed_soc_ast2600_init, | 46 | - .class_init = aspeed_soc_ast2600_class_init, |
91 | diff --git a/hw/misc/aspeed_scu.c b/hw/misc/aspeed_scu.c | 47 | - .class_size = sizeof(AspeedSoCClass), |
92 | index XXXXXXX..XXXXXXX 100644 | 48 | +static const TypeInfo aspeed_soc_ast2600_types[] = { |
93 | --- a/hw/misc/aspeed_scu.c | 49 | + { |
94 | +++ b/hw/misc/aspeed_scu.c | 50 | + .name = TYPE_ASPEED2600_SOC, |
95 | @@ -XXX,XX +XXX,XX @@ | 51 | + .parent = TYPE_ASPEED_SOC, |
96 | #define AST2600_CLK_STOP_CTRL_CLR TO_REG(0x84) | 52 | + .instance_size = sizeof(Aspeed2600SoCState), |
97 | #define AST2600_CLK_STOP_CTRL2 TO_REG(0x90) | 53 | + .abstract = true, |
98 | #define AST2600_CLK_STOP_CTRL2_CLR TO_REG(0x94) | 54 | + }, { |
99 | +#define AST2600_DEBUG_CTRL TO_REG(0xC8) | 55 | + .name = "ast2600-a3", |
100 | +#define AST2600_DEBUG_CTRL2 TO_REG(0xD8) | 56 | + .parent = TYPE_ASPEED2600_SOC, |
101 | #define AST2600_SDRAM_HANDSHAKE TO_REG(0x100) | 57 | + .instance_init = aspeed_soc_ast2600_init, |
102 | #define AST2600_HPLL_PARAM TO_REG(0x200) | 58 | + .class_init = aspeed_soc_ast2600_class_init, |
103 | #define AST2600_HPLL_EXT TO_REG(0x204) | 59 | + }, |
104 | +#define AST2600_APLL_PARAM TO_REG(0x210) | ||
105 | +#define AST2600_APLL_EXT TO_REG(0x214) | ||
106 | +#define AST2600_MPLL_PARAM TO_REG(0x220) | ||
107 | #define AST2600_MPLL_EXT TO_REG(0x224) | ||
108 | +#define AST2600_EPLL_PARAM TO_REG(0x240) | ||
109 | #define AST2600_EPLL_EXT TO_REG(0x244) | ||
110 | +#define AST2600_DPLL_PARAM TO_REG(0x260) | ||
111 | +#define AST2600_DPLL_EXT TO_REG(0x264) | ||
112 | #define AST2600_CLK_SEL TO_REG(0x300) | ||
113 | #define AST2600_CLK_SEL2 TO_REG(0x304) | ||
114 | -#define AST2600_CLK_SEL3 TO_REG(0x310) | ||
115 | +#define AST2600_CLK_SEL3 TO_REG(0x308) | ||
116 | +#define AST2600_CLK_SEL4 TO_REG(0x310) | ||
117 | +#define AST2600_CLK_SEL5 TO_REG(0x314) | ||
118 | #define AST2600_HW_STRAP1 TO_REG(0x500) | ||
119 | #define AST2600_HW_STRAP1_CLR TO_REG(0x504) | ||
120 | #define AST2600_HW_STRAP1_PROT TO_REG(0x508) | ||
121 | @@ -XXX,XX +XXX,XX @@ static uint32_t aspeed_silicon_revs[] = { | ||
122 | AST2500_A1_SILICON_REV, | ||
123 | AST2600_A0_SILICON_REV, | ||
124 | AST2600_A1_SILICON_REV, | ||
125 | + AST2600_A2_SILICON_REV, | ||
126 | + AST2600_A3_SILICON_REV, | ||
127 | }; | 60 | }; |
128 | 61 | ||
129 | bool is_supported_silicon_rev(uint32_t silicon_rev) | 62 | -static void aspeed_soc_register_types(void) |
130 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_ast2600_scu_ops = { | 63 | -{ |
131 | .valid.unaligned = false, | 64 | - type_register_static(&aspeed_soc_ast2600_type_info); |
132 | }; | 65 | -}; |
133 | |||
134 | -static const uint32_t ast2600_a1_resets[ASPEED_AST2600_SCU_NR_REGS] = { | ||
135 | +static const uint32_t ast2600_a3_resets[ASPEED_AST2600_SCU_NR_REGS] = { | ||
136 | [AST2600_SYS_RST_CTRL] = 0xF7C3FED8, | ||
137 | - [AST2600_SYS_RST_CTRL2] = 0xFFFFFFFC, | ||
138 | + [AST2600_SYS_RST_CTRL2] = 0x0DFFFFFC, | ||
139 | [AST2600_CLK_STOP_CTRL] = 0xFFFF7F8A, | ||
140 | [AST2600_CLK_STOP_CTRL2] = 0xFFF0FFF0, | ||
141 | + [AST2600_DEBUG_CTRL] = 0x00000FFF, | ||
142 | + [AST2600_DEBUG_CTRL2] = 0x000000FF, | ||
143 | [AST2600_SDRAM_HANDSHAKE] = 0x00000000, | ||
144 | - [AST2600_HPLL_PARAM] = 0x1000405F, | ||
145 | + [AST2600_HPLL_PARAM] = 0x1000408F, | ||
146 | + [AST2600_APLL_PARAM] = 0x1000405F, | ||
147 | + [AST2600_MPLL_PARAM] = 0x1008405F, | ||
148 | + [AST2600_EPLL_PARAM] = 0x1004077F, | ||
149 | + [AST2600_DPLL_PARAM] = 0x1078405F, | ||
150 | + [AST2600_CLK_SEL] = 0xF3940000, | ||
151 | + [AST2600_CLK_SEL2] = 0x00700000, | ||
152 | + [AST2600_CLK_SEL3] = 0x00000000, | ||
153 | + [AST2600_CLK_SEL4] = 0xF3F40000, | ||
154 | + [AST2600_CLK_SEL5] = 0x30000000, | ||
155 | [AST2600_CHIP_ID0] = 0x1234ABCD, | ||
156 | [AST2600_CHIP_ID1] = 0x88884444, | ||
157 | - | 66 | - |
158 | }; | 67 | -type_init(aspeed_soc_register_types) |
159 | 68 | +DEFINE_TYPES(aspeed_soc_ast2600_types) | |
160 | static void aspeed_ast2600_scu_reset(DeviceState *dev) | ||
161 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2600_scu_reset(DeviceState *dev) | ||
162 | * of actual revision. QEMU and Linux only support A1 onwards so this is | ||
163 | * sufficient. | ||
164 | */ | ||
165 | - s->regs[AST2600_SILICON_REV] = AST2600_A1_SILICON_REV; | ||
166 | + s->regs[AST2600_SILICON_REV] = AST2600_A3_SILICON_REV; | ||
167 | s->regs[AST2600_SILICON_REV2] = s->silicon_rev; | ||
168 | s->regs[AST2600_HW_STRAP1] = s->hw_strap1; | ||
169 | s->regs[AST2600_HW_STRAP2] = s->hw_strap2; | ||
170 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_scu_class_init(ObjectClass *klass, void *data) | ||
171 | |||
172 | dc->desc = "ASPEED 2600 System Control Unit"; | ||
173 | dc->reset = aspeed_ast2600_scu_reset; | ||
174 | - asc->resets = ast2600_a1_resets; | ||
175 | + asc->resets = ast2600_a3_resets; | ||
176 | asc->calc_hpll = aspeed_2500_scu_calc_hpll; /* No change since AST2500 */ | ||
177 | asc->apb_divider = 4; | ||
178 | asc->nr_regs = ASPEED_AST2600_SCU_NR_REGS; | ||
179 | -- | 69 | -- |
180 | 2.31.1 | 70 | 2.41.0 |
181 | 71 | ||
182 | 72 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There's no need to define the registers relative to the 0x800 offset | 3 | TYPE_ASPEED2400_SOC inherits from TYPE_ASPEED_SOC. |
4 | where the controller is mapped, as the device is instantiated as it's | 4 | In few commits we'll add more fields, but to keep |
5 | own model at the correct memory address. | 5 | review process simple, don't add any yet. |
6 | 6 | ||
7 | Simplify the defines and remove the offset to save future confusion. | 7 | TYPE_ASPEED_SOC is common to various Aspeed SoCs, |
8 | define it in aspeed_soc_common.c. | ||
8 | 9 | ||
9 | Signed-off-by: Joel Stanley <joel@jms.id.au> | 10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
10 | Reviewed-by: Rashmica Gupta <rashmica.g@gmail.com> | ||
11 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 11 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
12 | Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
13 | Message-Id: <20210713065854.134634-3-joel@jms.id.au> | ||
14 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
15 | --- | 13 | --- |
16 | hw/gpio/aspeed_gpio.c | 73 +++++++++++++++++++++---------------------- | 14 | include/hw/arm/aspeed_soc.h | 7 +++++ |
17 | 1 file changed, 36 insertions(+), 37 deletions(-) | 15 | hw/arm/aspeed_soc.c | 61 +++++++++++-------------------------- |
16 | hw/arm/aspeed_soc_common.c | 29 ++++++++++++++++++ | ||
17 | 3 files changed, 53 insertions(+), 44 deletions(-) | ||
18 | 18 | ||
19 | diff --git a/hw/gpio/aspeed_gpio.c b/hw/gpio/aspeed_gpio.c | 19 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
20 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
21 | --- a/hw/gpio/aspeed_gpio.c | 21 | --- a/include/hw/arm/aspeed_soc.h |
22 | +++ b/hw/gpio/aspeed_gpio.c | 22 | +++ b/include/hw/arm/aspeed_soc.h |
23 | @@ -XXX,XX +XXX,XX @@ struct AspeedSoCState { | ||
24 | #define TYPE_ASPEED_SOC "aspeed-soc" | ||
25 | OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC) | ||
26 | |||
27 | +struct Aspeed2400SoCState { | ||
28 | + AspeedSoCState parent; | ||
29 | +}; | ||
30 | + | ||
31 | +#define TYPE_ASPEED2400_SOC "aspeed2400-soc" | ||
32 | +OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2400SoCState, ASPEED2400_SOC) | ||
33 | + | ||
34 | struct Aspeed2600SoCState { | ||
35 | AspeedSoCState parent; | ||
36 | }; | ||
37 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/hw/arm/aspeed_soc.c | ||
40 | +++ b/hw/arm/aspeed_soc.c | ||
41 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp) | ||
42 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0, | ||
43 | aspeed_soc_get_irq(s, ASPEED_DEV_HACE)); | ||
44 | } | ||
45 | -static Property aspeed_soc_properties[] = { | ||
46 | - DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION, | ||
47 | - MemoryRegion *), | ||
48 | - DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION, | ||
49 | - MemoryRegion *), | ||
50 | - DEFINE_PROP_END_OF_LIST(), | ||
51 | -}; | ||
52 | - | ||
53 | -static void aspeed_soc_class_init(ObjectClass *oc, void *data) | ||
54 | -{ | ||
55 | - DeviceClass *dc = DEVICE_CLASS(oc); | ||
56 | - | ||
57 | - device_class_set_props(dc, aspeed_soc_properties); | ||
58 | -} | ||
59 | - | ||
60 | -static const TypeInfo aspeed_soc_type_info = { | ||
61 | - .name = TYPE_ASPEED_SOC, | ||
62 | - .parent = TYPE_DEVICE, | ||
63 | - .instance_size = sizeof(AspeedSoCState), | ||
64 | - .class_size = sizeof(AspeedSoCClass), | ||
65 | - .class_init = aspeed_soc_class_init, | ||
66 | - .abstract = true, | ||
67 | -}; | ||
68 | |||
69 | static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data) | ||
70 | { | ||
71 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data) | ||
72 | sc->get_irq = aspeed_soc_ast2400_get_irq; | ||
73 | } | ||
74 | |||
75 | -static const TypeInfo aspeed_soc_ast2400_type_info = { | ||
76 | - .name = "ast2400-a1", | ||
77 | - .parent = TYPE_ASPEED_SOC, | ||
78 | - .instance_init = aspeed_ast2400_soc_init, | ||
79 | - .instance_size = sizeof(AspeedSoCState), | ||
80 | - .class_init = aspeed_soc_ast2400_class_init, | ||
81 | -}; | ||
82 | - | ||
83 | static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data) | ||
84 | { | ||
85 | AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc); | ||
86 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data) | ||
87 | sc->get_irq = aspeed_soc_ast2400_get_irq; | ||
88 | } | ||
89 | |||
90 | -static const TypeInfo aspeed_soc_ast2500_type_info = { | ||
91 | - .name = "ast2500-a1", | ||
92 | - .parent = TYPE_ASPEED_SOC, | ||
93 | - .instance_init = aspeed_ast2400_soc_init, | ||
94 | - .instance_size = sizeof(AspeedSoCState), | ||
95 | - .class_init = aspeed_soc_ast2500_class_init, | ||
96 | -}; | ||
97 | -static void aspeed_soc_register_types(void) | ||
98 | -{ | ||
99 | - type_register_static(&aspeed_soc_type_info); | ||
100 | - type_register_static(&aspeed_soc_ast2400_type_info); | ||
101 | - type_register_static(&aspeed_soc_ast2500_type_info); | ||
102 | +static const TypeInfo aspeed_soc_ast2400_types[] = { | ||
103 | + { | ||
104 | + .name = TYPE_ASPEED2400_SOC, | ||
105 | + .parent = TYPE_ASPEED_SOC, | ||
106 | + .instance_init = aspeed_ast2400_soc_init, | ||
107 | + .instance_size = sizeof(Aspeed2400SoCState), | ||
108 | + .abstract = true, | ||
109 | + }, { | ||
110 | + .name = "ast2400-a1", | ||
111 | + .parent = TYPE_ASPEED2400_SOC, | ||
112 | + .class_init = aspeed_soc_ast2400_class_init, | ||
113 | + }, { | ||
114 | + .name = "ast2500-a1", | ||
115 | + .parent = TYPE_ASPEED2400_SOC, | ||
116 | + .class_init = aspeed_soc_ast2500_class_init, | ||
117 | + }, | ||
118 | }; | ||
119 | |||
120 | -type_init(aspeed_soc_register_types); | ||
121 | +DEFINE_TYPES(aspeed_soc_ast2400_types) | ||
122 | diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c | ||
123 | index XXXXXXX..XXXXXXX 100644 | ||
124 | --- a/hw/arm/aspeed_soc_common.c | ||
125 | +++ b/hw/arm/aspeed_soc_common.c | ||
23 | @@ -XXX,XX +XXX,XX @@ | 126 | @@ -XXX,XX +XXX,XX @@ |
24 | 127 | ||
25 | /* AST2600 only - 1.8V gpios */ | 128 | #include "qemu/osdep.h" |
26 | /* | 129 | #include "qapi/error.h" |
27 | - * The AST2600 has same 3.6V gpios as the AST2400 (memory offsets 0x0-0x198) | 130 | +#include "hw/qdev-properties.h" |
28 | - * and additional 1.8V gpios (memory offsets 0x800-0x9D4). | 131 | #include "hw/misc/unimp.h" |
29 | + * The AST2600 two copies of the GPIO controller: the same 3.6V gpios as the | 132 | #include "hw/arm/aspeed_soc.h" |
30 | + * AST2400 (memory offsets 0x0-0x198) and a second controller with 1.8V gpios | 133 | #include "hw/char/serial.h" |
31 | + * (memory offsets 0x800-0x9D4). | 134 | @@ -XXX,XX +XXX,XX @@ void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev, |
32 | */ | 135 | memory_region_add_subregion_overlap(s->memory, addr, |
33 | -#define GPIO_1_8V_REG_OFFSET 0x800 | 136 | sysbus_mmio_get_region(dev, 0), -1000); |
34 | -#define GPIO_1_8V_ABCD_DATA_VALUE ((0x800 - GPIO_1_8V_REG_OFFSET) >> 2) | 137 | } |
35 | -#define GPIO_1_8V_ABCD_DIRECTION ((0x804 - GPIO_1_8V_REG_OFFSET) >> 2) | 138 | + |
36 | -#define GPIO_1_8V_ABCD_INT_ENABLE ((0x808 - GPIO_1_8V_REG_OFFSET) >> 2) | 139 | +static Property aspeed_soc_properties[] = { |
37 | -#define GPIO_1_8V_ABCD_INT_SENS_0 ((0x80C - GPIO_1_8V_REG_OFFSET) >> 2) | 140 | + DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION, |
38 | -#define GPIO_1_8V_ABCD_INT_SENS_1 ((0x810 - GPIO_1_8V_REG_OFFSET) >> 2) | 141 | + MemoryRegion *), |
39 | -#define GPIO_1_8V_ABCD_INT_SENS_2 ((0x814 - GPIO_1_8V_REG_OFFSET) >> 2) | 142 | + DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION, |
40 | -#define GPIO_1_8V_ABCD_INT_STATUS ((0x818 - GPIO_1_8V_REG_OFFSET) >> 2) | 143 | + MemoryRegion *), |
41 | -#define GPIO_1_8V_ABCD_RESET_TOLERANT ((0x81C - GPIO_1_8V_REG_OFFSET) >> 2) | 144 | + DEFINE_PROP_END_OF_LIST(), |
42 | -#define GPIO_1_8V_E_DATA_VALUE ((0x820 - GPIO_1_8V_REG_OFFSET) >> 2) | 145 | +}; |
43 | -#define GPIO_1_8V_E_DIRECTION ((0x824 - GPIO_1_8V_REG_OFFSET) >> 2) | 146 | + |
44 | -#define GPIO_1_8V_E_INT_ENABLE ((0x828 - GPIO_1_8V_REG_OFFSET) >> 2) | 147 | +static void aspeed_soc_class_init(ObjectClass *oc, void *data) |
45 | -#define GPIO_1_8V_E_INT_SENS_0 ((0x82C - GPIO_1_8V_REG_OFFSET) >> 2) | 148 | +{ |
46 | -#define GPIO_1_8V_E_INT_SENS_1 ((0x830 - GPIO_1_8V_REG_OFFSET) >> 2) | 149 | + DeviceClass *dc = DEVICE_CLASS(oc); |
47 | -#define GPIO_1_8V_E_INT_SENS_2 ((0x834 - GPIO_1_8V_REG_OFFSET) >> 2) | 150 | + |
48 | -#define GPIO_1_8V_E_INT_STATUS ((0x838 - GPIO_1_8V_REG_OFFSET) >> 2) | 151 | + device_class_set_props(dc, aspeed_soc_properties); |
49 | -#define GPIO_1_8V_E_RESET_TOLERANT ((0x83C - GPIO_1_8V_REG_OFFSET) >> 2) | 152 | +} |
50 | -#define GPIO_1_8V_ABCD_DEBOUNCE_1 ((0x840 - GPIO_1_8V_REG_OFFSET) >> 2) | 153 | + |
51 | -#define GPIO_1_8V_ABCD_DEBOUNCE_2 ((0x844 - GPIO_1_8V_REG_OFFSET) >> 2) | 154 | +static const TypeInfo aspeed_soc_types[] = { |
52 | -#define GPIO_1_8V_E_DEBOUNCE_1 ((0x848 - GPIO_1_8V_REG_OFFSET) >> 2) | 155 | + { |
53 | -#define GPIO_1_8V_E_DEBOUNCE_2 ((0x84C - GPIO_1_8V_REG_OFFSET) >> 2) | 156 | + .name = TYPE_ASPEED_SOC, |
54 | -#define GPIO_1_8V_DEBOUNCE_TIME_1 ((0x850 - GPIO_1_8V_REG_OFFSET) >> 2) | 157 | + .parent = TYPE_DEVICE, |
55 | -#define GPIO_1_8V_DEBOUNCE_TIME_2 ((0x854 - GPIO_1_8V_REG_OFFSET) >> 2) | 158 | + .instance_size = sizeof(AspeedSoCState), |
56 | -#define GPIO_1_8V_DEBOUNCE_TIME_3 ((0x858 - GPIO_1_8V_REG_OFFSET) >> 2) | 159 | + .class_size = sizeof(AspeedSoCClass), |
57 | -#define GPIO_1_8V_ABCD_COMMAND_SRC_0 ((0x860 - GPIO_1_8V_REG_OFFSET) >> 2) | 160 | + .class_init = aspeed_soc_class_init, |
58 | -#define GPIO_1_8V_ABCD_COMMAND_SRC_1 ((0x864 - GPIO_1_8V_REG_OFFSET) >> 2) | 161 | + .abstract = true, |
59 | -#define GPIO_1_8V_E_COMMAND_SRC_0 ((0x868 - GPIO_1_8V_REG_OFFSET) >> 2) | 162 | + }, |
60 | -#define GPIO_1_8V_E_COMMAND_SRC_1 ((0x86C - GPIO_1_8V_REG_OFFSET) >> 2) | 163 | +}; |
61 | -#define GPIO_1_8V_ABCD_DATA_READ ((0x8C0 - GPIO_1_8V_REG_OFFSET) >> 2) | 164 | + |
62 | -#define GPIO_1_8V_E_DATA_READ ((0x8C4 - GPIO_1_8V_REG_OFFSET) >> 2) | 165 | +DEFINE_TYPES(aspeed_soc_types) |
63 | -#define GPIO_1_8V_ABCD_INPUT_MASK ((0x9D0 - GPIO_1_8V_REG_OFFSET) >> 2) | ||
64 | -#define GPIO_1_8V_E_INPUT_MASK ((0x9D4 - GPIO_1_8V_REG_OFFSET) >> 2) | ||
65 | -#define GPIO_1_8V_MEM_SIZE 0x9D8 | ||
66 | -#define GPIO_1_8V_REG_ARRAY_SIZE ((GPIO_1_8V_MEM_SIZE - \ | ||
67 | - GPIO_1_8V_REG_OFFSET) >> 2) | ||
68 | +#define GPIO_1_8V_ABCD_DATA_VALUE (0x000 >> 2) | ||
69 | +#define GPIO_1_8V_ABCD_DIRECTION (0x004 >> 2) | ||
70 | +#define GPIO_1_8V_ABCD_INT_ENABLE (0x008 >> 2) | ||
71 | +#define GPIO_1_8V_ABCD_INT_SENS_0 (0x00C >> 2) | ||
72 | +#define GPIO_1_8V_ABCD_INT_SENS_1 (0x010 >> 2) | ||
73 | +#define GPIO_1_8V_ABCD_INT_SENS_2 (0x014 >> 2) | ||
74 | +#define GPIO_1_8V_ABCD_INT_STATUS (0x018 >> 2) | ||
75 | +#define GPIO_1_8V_ABCD_RESET_TOLERANT (0x01C >> 2) | ||
76 | +#define GPIO_1_8V_E_DATA_VALUE (0x020 >> 2) | ||
77 | +#define GPIO_1_8V_E_DIRECTION (0x024 >> 2) | ||
78 | +#define GPIO_1_8V_E_INT_ENABLE (0x028 >> 2) | ||
79 | +#define GPIO_1_8V_E_INT_SENS_0 (0x02C >> 2) | ||
80 | +#define GPIO_1_8V_E_INT_SENS_1 (0x030 >> 2) | ||
81 | +#define GPIO_1_8V_E_INT_SENS_2 (0x034 >> 2) | ||
82 | +#define GPIO_1_8V_E_INT_STATUS (0x038 >> 2) | ||
83 | +#define GPIO_1_8V_E_RESET_TOLERANT (0x03C >> 2) | ||
84 | +#define GPIO_1_8V_ABCD_DEBOUNCE_1 (0x040 >> 2) | ||
85 | +#define GPIO_1_8V_ABCD_DEBOUNCE_2 (0x044 >> 2) | ||
86 | +#define GPIO_1_8V_E_DEBOUNCE_1 (0x048 >> 2) | ||
87 | +#define GPIO_1_8V_E_DEBOUNCE_2 (0x04C >> 2) | ||
88 | +#define GPIO_1_8V_DEBOUNCE_TIME_1 (0x050 >> 2) | ||
89 | +#define GPIO_1_8V_DEBOUNCE_TIME_2 (0x054 >> 2) | ||
90 | +#define GPIO_1_8V_DEBOUNCE_TIME_3 (0x058 >> 2) | ||
91 | +#define GPIO_1_8V_ABCD_COMMAND_SRC_0 (0x060 >> 2) | ||
92 | +#define GPIO_1_8V_ABCD_COMMAND_SRC_1 (0x064 >> 2) | ||
93 | +#define GPIO_1_8V_E_COMMAND_SRC_0 (0x068 >> 2) | ||
94 | +#define GPIO_1_8V_E_COMMAND_SRC_1 (0x06C >> 2) | ||
95 | +#define GPIO_1_8V_ABCD_DATA_READ (0x0C0 >> 2) | ||
96 | +#define GPIO_1_8V_E_DATA_READ (0x0C4 >> 2) | ||
97 | +#define GPIO_1_8V_ABCD_INPUT_MASK (0x1D0 >> 2) | ||
98 | +#define GPIO_1_8V_E_INPUT_MASK (0x1D4 >> 2) | ||
99 | +#define GPIO_1_8V_MEM_SIZE 0x1D8 | ||
100 | +#define GPIO_1_8V_REG_ARRAY_SIZE (GPIO_1_8V_MEM_SIZE >> 2) | ||
101 | |||
102 | static int aspeed_evaluate_irq(GPIOSets *regs, int gpio_prev_high, int gpio) | ||
103 | { | ||
104 | -- | 166 | -- |
105 | 2.31.1 | 167 | 2.41.0 |
106 | 168 | ||
107 | 169 | diff view generated by jsdifflib |
1 | From: Joel Stanley <joel@jms.id.au> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | These are the devices documented by the Rainier device tree. With this | 3 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
4 | we can see the guest discovering the multiplexers and probing the eeprom | 4 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
5 | devices: | ||
6 | |||
7 | i2c i2c-2: Added multiplexed i2c bus 16 | ||
8 | i2c i2c-2: Added multiplexed i2c bus 17 | ||
9 | i2c i2c-2: Added multiplexed i2c bus 18 | ||
10 | i2c i2c-2: Added multiplexed i2c bus 19 | ||
11 | i2c-mux-gpio i2cmux: 4 port mux on 1e78a180.i2c-bus adapter | ||
12 | at24 20-0050: 8192 byte 24c64 EEPROM, writable, 1 bytes/write | ||
13 | i2c i2c-4: Added multiplexed i2c bus 20 | ||
14 | at24 21-0051: 8192 byte 24c64 EEPROM, writable, 1 bytes/write | ||
15 | i2c i2c-4: Added multiplexed i2c bus 21 | ||
16 | at24 22-0052: 8192 byte 24c64 EEPROM, writable, 1 bytes/write | ||
17 | |||
18 | Signed-off-by: Joel Stanley <joel@jms.id.au> | ||
19 | [ clg: Introduced aspeed_eeprom_init ] | ||
20 | Message-Id: <20210629142336.750058-2-clg@kaod.org> | ||
21 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 5 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
22 | --- | 6 | --- |
23 | hw/arm/aspeed.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ | 7 | hw/arm/aspeed_soc_common.c | 11 +++++++++++ |
24 | 1 file changed, 44 insertions(+) | 8 | 1 file changed, 11 insertions(+) |
25 | 9 | ||
26 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | 10 | diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c |
27 | index XXXXXXX..XXXXXXX 100644 | 11 | index XXXXXXX..XXXXXXX 100644 |
28 | --- a/hw/arm/aspeed.c | 12 | --- a/hw/arm/aspeed_soc_common.c |
29 | +++ b/hw/arm/aspeed.c | 13 | +++ b/hw/arm/aspeed_soc_common.c |
30 | @@ -XXX,XX +XXX,XX @@ static void g220a_bmc_i2c_init(AspeedMachineState *bmc) | 14 | @@ -XXX,XX +XXX,XX @@ void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev, |
31 | eeprom_buf); | 15 | sysbus_mmio_get_region(dev, 0), -1000); |
32 | } | 16 | } |
33 | 17 | ||
34 | +static void aspeed_eeprom_init(I2CBus *bus, uint8_t addr, uint32_t rsize) | 18 | +static void aspeed_soc_realize(DeviceState *dev, Error **errp) |
35 | +{ | 19 | +{ |
36 | + I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr); | 20 | + AspeedSoCState *s = ASPEED_SOC(dev); |
37 | + DeviceState *dev = DEVICE(i2c_dev); | ||
38 | + | 21 | + |
39 | + qdev_prop_set_uint32(dev, "rom-size", rsize); | 22 | + if (!s->memory) { |
40 | + i2c_slave_realize_and_unref(i2c_dev, bus, &error_abort); | 23 | + error_setg(errp, "'memory' link is not set"); |
24 | + return; | ||
25 | + } | ||
41 | +} | 26 | +} |
42 | + | 27 | + |
43 | static void rainier_bmc_i2c_init(AspeedMachineState *bmc) | 28 | static Property aspeed_soc_properties[] = { |
29 | DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION, | ||
30 | MemoryRegion *), | ||
31 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_class_init(ObjectClass *oc, void *data) | ||
44 | { | 32 | { |
45 | AspeedSoCState *soc = &bmc->soc; | 33 | DeviceClass *dc = DEVICE_CLASS(oc); |
46 | + I2CSlave *i2c_mux; | 34 | |
47 | + | 35 | + dc->realize = aspeed_soc_realize; |
48 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 0), 0x51, 32 * KiB); | 36 | device_class_set_props(dc, aspeed_soc_properties); |
49 | |||
50 | /* The rainier expects a TMP275 but a TMP105 is compatible */ | ||
51 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, | ||
52 | @@ -XXX,XX +XXX,XX @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) | ||
53 | 0x49); | ||
54 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), TYPE_TMP105, | ||
55 | 0x4a); | ||
56 | + i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 4), | ||
57 | + "pca9546", 0x70); | ||
58 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); | ||
59 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); | ||
60 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x52, 64 * KiB); | ||
61 | |||
62 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105, | ||
63 | 0x48); | ||
64 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), TYPE_TMP105, | ||
65 | 0x49); | ||
66 | + i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 5), | ||
67 | + "pca9546", 0x70); | ||
68 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); | ||
69 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); | ||
70 | |||
71 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, | ||
72 | 0x48); | ||
73 | @@ -XXX,XX +XXX,XX @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) | ||
74 | 0x4a); | ||
75 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), TYPE_TMP105, | ||
76 | 0x4b); | ||
77 | + i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 6), | ||
78 | + "pca9546", 0x70); | ||
79 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); | ||
80 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); | ||
81 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 2), 0x50, 64 * KiB); | ||
82 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 3), 0x51, 64 * KiB); | ||
83 | |||
84 | /* Bus 7: TODO dps310@76 */ | ||
85 | /* Bus 7: TODO max31785@52 */ | ||
86 | @@ -XXX,XX +XXX,XX @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) | ||
87 | /* Bus 7: TODO si7021-a20@20 */ | ||
88 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 7), TYPE_TMP105, | ||
89 | 0x48); | ||
90 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x50, 64 * KiB); | ||
91 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 7), 0x51, 64 * KiB); | ||
92 | |||
93 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105, | ||
94 | 0x48); | ||
95 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), TYPE_TMP105, | ||
96 | 0x4a); | ||
97 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x50, 64 * KiB); | ||
98 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 8), 0x51, 64 * KiB); | ||
99 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 8), "pca9552", 0x61); | ||
100 | /* Bus 8: ucd90320@11 */ | ||
101 | /* Bus 8: ucd90320@b */ | ||
102 | @@ -XXX,XX +XXX,XX @@ static void rainier_bmc_i2c_init(AspeedMachineState *bmc) | ||
103 | |||
104 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4c); | ||
105 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 9), "tmp423", 0x4d); | ||
106 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 9), 0x50, 128 * KiB); | ||
107 | |||
108 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4c); | ||
109 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 10), "tmp423", 0x4d); | ||
110 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 10), 0x50, 128 * KiB); | ||
111 | |||
112 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105, | ||
113 | 0x48); | ||
114 | i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), TYPE_TMP105, | ||
115 | 0x49); | ||
116 | + i2c_mux = i2c_slave_create_simple(aspeed_i2c_get_bus(&soc->i2c, 11), | ||
117 | + "pca9546", 0x70); | ||
118 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 0), 0x50, 64 * KiB); | ||
119 | + aspeed_eeprom_init(pca954x_i2c_get_bus(i2c_mux, 1), 0x51, 64 * KiB); | ||
120 | + | ||
121 | + | ||
122 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 13), 0x50, 64 * KiB); | ||
123 | + | ||
124 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 14), 0x50, 64 * KiB); | ||
125 | + | ||
126 | + aspeed_eeprom_init(aspeed_i2c_get_bus(&soc->i2c, 15), 0x50, 64 * KiB); | ||
127 | } | 37 | } |
128 | 38 | ||
129 | static bool aspeed_get_mmio_exec(Object *obj, Error **errp) | ||
130 | -- | 39 | -- |
131 | 2.31.1 | 40 | 2.41.0 |
132 | 41 | ||
133 | 42 | diff view generated by jsdifflib |
1 | From: Andrew Jeffery <andrew@aj.id.au> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | While some of the critical fields remain the same, there is variation in | 3 | The v7-M core is specific to the Aspeed 10x0 series, |
4 | the definition of the control register across the SoC generations. | 4 | remove it from the common AspeedSoCState. |
5 | Reserved regions are adjusted, while in other cases the mutability or | ||
6 | behaviour of fields change. | ||
7 | 5 | ||
8 | Introduce a callback to sanitize the value on writes to ensure model | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | behaviour reflects the hardware. | ||
10 | |||
11 | Fixes: 854123bf8d4b ("wdt: Add Aspeed watchdog device model") | ||
12 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
13 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
14 | Message-Id: <20210709053107.1829304-2-andrew@aj.id.au> | ||
15 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
16 | --- | 9 | --- |
17 | include/hw/watchdog/wdt_aspeed.h | 1 + | 10 | include/hw/arm/aspeed_soc.h | 5 ++--- |
18 | hw/watchdog/wdt_aspeed.c | 24 ++++++++++++++++++++++-- | 11 | hw/arm/aspeed_ast10x0.c | 27 +++++++++++++++------------ |
19 | 2 files changed, 23 insertions(+), 2 deletions(-) | 12 | hw/arm/fby35.c | 13 ++++++++----- |
13 | 3 files changed, 25 insertions(+), 20 deletions(-) | ||
20 | 14 | ||
21 | diff --git a/include/hw/watchdog/wdt_aspeed.h b/include/hw/watchdog/wdt_aspeed.h | 15 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
22 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/watchdog/wdt_aspeed.h | 17 | --- a/include/hw/arm/aspeed_soc.h |
24 | +++ b/include/hw/watchdog/wdt_aspeed.h | 18 | +++ b/include/hw/arm/aspeed_soc.h |
25 | @@ -XXX,XX +XXX,XX @@ struct AspeedWDTClass { | 19 | @@ -XXX,XX +XXX,XX @@ |
26 | uint32_t reset_ctrl_reg; | 20 | #define ASPEED_JTAG_NUM 2 |
27 | void (*reset_pulse)(AspeedWDTState *s, uint32_t property); | 21 | |
28 | void (*wdt_reload)(AspeedWDTState *s); | 22 | struct AspeedSoCState { |
29 | + uint64_t (*sanitize_ctrl)(uint64_t data); | 23 | - /*< private >*/ |
24 | DeviceState parent; | ||
25 | |||
26 | - /*< public >*/ | ||
27 | ARMCPU cpu[ASPEED_CPUS_NUM]; | ||
28 | A15MPPrivState a7mpcore; | ||
29 | - ARMv7MState armv7m; | ||
30 | MemoryRegion *memory; | ||
31 | MemoryRegion *dram_mr; | ||
32 | MemoryRegion dram_container; | ||
33 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2600SoCState, ASPEED2600_SOC) | ||
34 | |||
35 | struct Aspeed10x0SoCState { | ||
36 | AspeedSoCState parent; | ||
37 | + | ||
38 | + ARMv7MState armv7m; | ||
30 | }; | 39 | }; |
31 | 40 | ||
32 | #endif /* WDT_ASPEED_H */ | 41 | #define TYPE_ASPEED10X0_SOC "aspeed10x0-soc" |
33 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | 42 | diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c |
34 | index XXXXXXX..XXXXXXX 100644 | 43 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/hw/watchdog/wdt_aspeed.c | 44 | --- a/hw/arm/aspeed_ast10x0.c |
36 | +++ b/hw/watchdog/wdt_aspeed.c | 45 | +++ b/hw/arm/aspeed_ast10x0.c |
37 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_reload_1mhz(AspeedWDTState *s) | 46 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast1030_irqmap[] = { |
47 | |||
48 | static qemu_irq aspeed_soc_ast1030_get_irq(AspeedSoCState *s, int dev) | ||
49 | { | ||
50 | + Aspeed10x0SoCState *a = ASPEED10X0_SOC(s); | ||
51 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
52 | |||
53 | - return qdev_get_gpio_in(DEVICE(&s->armv7m), sc->irqmap[dev]); | ||
54 | + return qdev_get_gpio_in(DEVICE(&a->armv7m), sc->irqmap[dev]); | ||
55 | } | ||
56 | |||
57 | static void aspeed_soc_ast1030_init(Object *obj) | ||
58 | { | ||
59 | + Aspeed10x0SoCState *a = ASPEED10X0_SOC(obj); | ||
60 | AspeedSoCState *s = ASPEED_SOC(obj); | ||
61 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
62 | char socname[8]; | ||
63 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_init(Object *obj) | ||
64 | g_assert_not_reached(); | ||
38 | } | 65 | } |
66 | |||
67 | - object_initialize_child(obj, "armv7m", &s->armv7m, TYPE_ARMV7M); | ||
68 | + object_initialize_child(obj, "armv7m", &a->armv7m, TYPE_ARMV7M); | ||
69 | |||
70 | s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0); | ||
71 | |||
72 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_init(Object *obj) | ||
73 | |||
74 | static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) | ||
75 | { | ||
76 | + Aspeed10x0SoCState *a = ASPEED10X0_SOC(dev_soc); | ||
77 | AspeedSoCState *s = ASPEED_SOC(dev_soc); | ||
78 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
79 | DeviceState *armv7m; | ||
80 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) | ||
81 | 0x40000); | ||
82 | |||
83 | /* AST1030 CPU Core */ | ||
84 | - armv7m = DEVICE(&s->armv7m); | ||
85 | + armv7m = DEVICE(&a->armv7m); | ||
86 | qdev_prop_set_uint32(armv7m, "num-irq", 256); | ||
87 | qdev_prop_set_string(armv7m, "cpu-type", sc->cpu_type); | ||
88 | qdev_connect_clock_in(armv7m, "cpuclk", s->sysclk); | ||
89 | - object_property_set_link(OBJECT(&s->armv7m), "memory", | ||
90 | + object_property_set_link(OBJECT(&a->armv7m), "memory", | ||
91 | OBJECT(s->memory), &error_abort); | ||
92 | - sysbus_realize(SYS_BUS_DEVICE(&s->armv7m), &error_abort); | ||
93 | + sysbus_realize(SYS_BUS_DEVICE(&a->armv7m), &error_abort); | ||
94 | |||
95 | /* Internal SRAM */ | ||
96 | sram_name = g_strdup_printf("aspeed.sram.%d", | ||
97 | - CPU(s->armv7m.cpu)->cpu_index); | ||
98 | + CPU(a->armv7m.cpu)->cpu_index); | ||
99 | memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err); | ||
100 | if (err != NULL) { | ||
101 | error_propagate(errp, err); | ||
102 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) | ||
103 | } | ||
104 | aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); | ||
105 | for (i = 0; i < ASPEED_I2C_GET_CLASS(&s->i2c)->num_busses; i++) { | ||
106 | - qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
107 | + qemu_irq irq = qdev_get_gpio_in(DEVICE(&a->armv7m), | ||
108 | sc->irqmap[ASPEED_DEV_I2C] + i); | ||
109 | /* The AST1030 I2C controller has one IRQ per bus. */ | ||
110 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c.busses[i]), 0, irq); | ||
111 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) | ||
112 | } | ||
113 | aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]); | ||
114 | for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) { | ||
115 | - qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
116 | + qemu_irq irq = qdev_get_gpio_in(DEVICE(&a->armv7m), | ||
117 | sc->irqmap[ASPEED_DEV_I3C] + i); | ||
118 | /* The AST1030 I3C controller has one IRQ per bus. */ | ||
119 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq); | ||
120 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast1030_realize(DeviceState *dev_soc, Error **errp) | ||
121 | * On the AST1030 LPC subdevice IRQs are connected straight to the GIC. | ||
122 | */ | ||
123 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1, | ||
124 | - qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
125 | + qdev_get_gpio_in(DEVICE(&a->armv7m), | ||
126 | sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_1)); | ||
127 | |||
128 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2, | ||
129 | - qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
130 | + qdev_get_gpio_in(DEVICE(&a->armv7m), | ||
131 | sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_2)); | ||
132 | |||
133 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3, | ||
134 | - qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
135 | + qdev_get_gpio_in(DEVICE(&a->armv7m), | ||
136 | sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_3)); | ||
137 | |||
138 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4, | ||
139 | - qdev_get_gpio_in(DEVICE(&s->armv7m), | ||
140 | + qdev_get_gpio_in(DEVICE(&a->armv7m), | ||
141 | sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4)); | ||
142 | |||
143 | /* UART */ | ||
144 | diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c | ||
145 | index XXXXXXX..XXXXXXX 100644 | ||
146 | --- a/hw/arm/fby35.c | ||
147 | +++ b/hw/arm/fby35.c | ||
148 | @@ -XXX,XX +XXX,XX @@ struct Fby35State { | ||
149 | Clock *bic_sysclk; | ||
150 | |||
151 | AspeedSoCState bmc; | ||
152 | - AspeedSoCState bic; | ||
153 | + Aspeed10x0SoCState bic; | ||
154 | |||
155 | bool mmio_exec; | ||
156 | }; | ||
157 | @@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s) | ||
158 | |||
159 | static void fby35_bic_init(Fby35State *s) | ||
160 | { | ||
161 | + AspeedSoCState *soc; | ||
162 | + | ||
163 | s->bic_sysclk = clock_new(OBJECT(s), "SYSCLK"); | ||
164 | clock_set_hz(s->bic_sysclk, 200000000ULL); | ||
165 | |||
166 | object_initialize_child(OBJECT(s), "bic", &s->bic, "ast1030-a1"); | ||
167 | + soc = ASPEED_SOC(&s->bic); | ||
168 | |||
169 | memory_region_init(&s->bic_memory, OBJECT(&s->bic), "bic-memory", | ||
170 | UINT64_MAX); | ||
171 | @@ -XXX,XX +XXX,XX @@ static void fby35_bic_init(Fby35State *s) | ||
172 | qdev_connect_clock_in(DEVICE(&s->bic), "sysclk", s->bic_sysclk); | ||
173 | object_property_set_link(OBJECT(&s->bic), "memory", OBJECT(&s->bic_memory), | ||
174 | &error_abort); | ||
175 | - aspeed_soc_uart_set_chr(&s->bic, ASPEED_DEV_UART5, serial_hd(1)); | ||
176 | + aspeed_soc_uart_set_chr(soc, ASPEED_DEV_UART5, serial_hd(1)); | ||
177 | qdev_realize(DEVICE(&s->bic), NULL, &error_abort); | ||
178 | |||
179 | - aspeed_board_init_flashes(&s->bic.fmc, "sst25vf032b", 2, 2); | ||
180 | - aspeed_board_init_flashes(&s->bic.spi[0], "sst25vf032b", 2, 4); | ||
181 | - aspeed_board_init_flashes(&s->bic.spi[1], "sst25vf032b", 2, 6); | ||
182 | + aspeed_board_init_flashes(&soc->fmc, "sst25vf032b", 2, 2); | ||
183 | + aspeed_board_init_flashes(&soc->spi[0], "sst25vf032b", 2, 4); | ||
184 | + aspeed_board_init_flashes(&soc->spi[1], "sst25vf032b", 2, 6); | ||
39 | } | 185 | } |
40 | 186 | ||
41 | +static uint64_t aspeed_2400_sanitize_ctrl(uint64_t data) | 187 | static void fby35_init(MachineState *machine) |
42 | +{ | ||
43 | + return data & 0xffff; | ||
44 | +} | ||
45 | + | ||
46 | +static uint64_t aspeed_2500_sanitize_ctrl(uint64_t data) | ||
47 | +{ | ||
48 | + return (data & ~(0xfUL << 8)) | WDT_CTRL_1MHZ_CLK; | ||
49 | +} | ||
50 | + | ||
51 | +static uint64_t aspeed_2600_sanitize_ctrl(uint64_t data) | ||
52 | +{ | ||
53 | + return data & ~(0x7UL << 7); | ||
54 | +} | ||
55 | |||
56 | static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data, | ||
57 | unsigned size) | ||
58 | { | ||
59 | AspeedWDTState *s = ASPEED_WDT(opaque); | ||
60 | AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(s); | ||
61 | - bool enable = data & WDT_CTRL_ENABLE; | ||
62 | + bool enable; | ||
63 | |||
64 | offset >>= 2; | ||
65 | |||
66 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data, | ||
67 | } | ||
68 | break; | ||
69 | case WDT_CTRL: | ||
70 | + data = awc->sanitize_ctrl(data); | ||
71 | + enable = data & WDT_CTRL_ENABLE; | ||
72 | if (enable && !aspeed_wdt_is_enabled(s)) { | ||
73 | s->regs[WDT_CTRL] = data; | ||
74 | awc->wdt_reload(s); | ||
75 | @@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps aspeed_wdt_ops = { | ||
76 | static void aspeed_wdt_reset(DeviceState *dev) | ||
77 | { | ||
78 | AspeedWDTState *s = ASPEED_WDT(dev); | ||
79 | + AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(s); | ||
80 | |||
81 | s->regs[WDT_STATUS] = 0x3EF1480; | ||
82 | s->regs[WDT_RELOAD_VALUE] = 0x03EF1480; | ||
83 | s->regs[WDT_RESTART] = 0; | ||
84 | - s->regs[WDT_CTRL] = 0; | ||
85 | + s->regs[WDT_CTRL] = awc->sanitize_ctrl(0); | ||
86 | s->regs[WDT_RESET_WIDTH] = 0xFF; | ||
87 | |||
88 | timer_del(s->timer); | ||
89 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2400_wdt_class_init(ObjectClass *klass, void *data) | ||
90 | awc->ext_pulse_width_mask = 0xff; | ||
91 | awc->reset_ctrl_reg = SCU_RESET_CONTROL1; | ||
92 | awc->wdt_reload = aspeed_wdt_reload; | ||
93 | + awc->sanitize_ctrl = aspeed_2400_sanitize_ctrl; | ||
94 | } | ||
95 | |||
96 | static const TypeInfo aspeed_2400_wdt_info = { | ||
97 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2500_wdt_class_init(ObjectClass *klass, void *data) | ||
98 | awc->reset_ctrl_reg = SCU_RESET_CONTROL1; | ||
99 | awc->reset_pulse = aspeed_2500_wdt_reset_pulse; | ||
100 | awc->wdt_reload = aspeed_wdt_reload_1mhz; | ||
101 | + awc->sanitize_ctrl = aspeed_2500_sanitize_ctrl; | ||
102 | } | ||
103 | |||
104 | static const TypeInfo aspeed_2500_wdt_info = { | ||
105 | @@ -XXX,XX +XXX,XX @@ static void aspeed_2600_wdt_class_init(ObjectClass *klass, void *data) | ||
106 | awc->reset_ctrl_reg = AST2600_SCU_RESET_CONTROL1; | ||
107 | awc->reset_pulse = aspeed_2500_wdt_reset_pulse; | ||
108 | awc->wdt_reload = aspeed_wdt_reload_1mhz; | ||
109 | + awc->sanitize_ctrl = aspeed_2600_sanitize_ctrl; | ||
110 | } | ||
111 | |||
112 | static const TypeInfo aspeed_2600_wdt_info = { | ||
113 | -- | 188 | -- |
114 | 2.31.1 | 189 | 2.41.0 |
115 | 190 | ||
116 | 191 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Andrew Jeffery <andrew@aj.id.au> | ||
2 | 1 | ||
3 | The logic in the handling for the control register required toggling the | ||
4 | enable state for writes to stick. Rework the condition chain to allow | ||
5 | sequential writes that do not update the enable state. | ||
6 | |||
7 | Fixes: 854123bf8d4b ("wdt: Add Aspeed watchdog device model") | ||
8 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
9 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | ||
10 | Message-Id: <20210709053107.1829304-3-andrew@aj.id.au> | ||
11 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | ||
12 | --- | ||
13 | hw/watchdog/wdt_aspeed.c | 2 ++ | ||
14 | 1 file changed, 2 insertions(+) | ||
15 | |||
16 | diff --git a/hw/watchdog/wdt_aspeed.c b/hw/watchdog/wdt_aspeed.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/hw/watchdog/wdt_aspeed.c | ||
19 | +++ b/hw/watchdog/wdt_aspeed.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data, | ||
21 | } else if (!enable && aspeed_wdt_is_enabled(s)) { | ||
22 | s->regs[WDT_CTRL] = data; | ||
23 | timer_del(s->timer); | ||
24 | + } else { | ||
25 | + s->regs[WDT_CTRL] = data; | ||
26 | } | ||
27 | break; | ||
28 | case WDT_RESET_WIDTH: | ||
29 | -- | ||
30 | 2.31.1 | ||
31 | |||
32 | diff view generated by jsdifflib |
1 | From: Peter Delevoryas <pdel@fb.com> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | When you run QEMU with an Aspeed machine and a single serial device | 3 | The v7-A cluster is specific to the Aspeed 2600 series, |
4 | using stdio like this: | 4 | remove it from the common AspeedSoCState. |
5 | 5 | ||
6 | qemu -machine ast2600-evb -drive ... -serial stdio | 6 | The ARM cores belong to the MP cluster, but the array |
7 | 7 | is currently used by TYPE_ASPEED2600_SOC. We'll clean | |
8 | The guest OS can read and write to the UART5 registers at 0x1E784000 and | 8 | that soon, but for now keep it in Aspeed2600SoCState. |
9 | it will receive from stdin and write to stdout. The Aspeed SoC's have a | 9 | |
10 | lot more UART's though (AST2500 has 5, AST2600 has 13) and depending on | 10 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
11 | the board design, may be using any of them as the serial console. (See | ||
12 | "stdout-path" in a DTS to check which one is chosen). | ||
13 | |||
14 | Most boards, including all of those currently defined in | ||
15 | hw/arm/aspeed.c, just use UART5, but some use UART1. This change adds | ||
16 | some flexibility for different boards without requiring users to change | ||
17 | their command-line invocation of QEMU. | ||
18 | |||
19 | I tested this doesn't break existing code by booting an AST2500 OpenBMC | ||
20 | image and an AST2600 OpenBMC image, each using UART5 as the console. | ||
21 | |||
22 | Then I tested switching the default to UART1 and booting an AST2600 | ||
23 | OpenBMC image that uses UART1, and that worked too. | ||
24 | |||
25 | Signed-off-by: Peter Delevoryas <pdel@fb.com> | ||
26 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 11 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
27 | Message-Id: <20210901153615.2746885-2-pdel@fb.com> | ||
28 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
29 | --- | 13 | --- |
30 | include/hw/arm/aspeed.h | 1 + | 14 | include/hw/arm/aspeed_soc.h | 4 ++- |
31 | include/hw/arm/aspeed_soc.h | 1 + | 15 | hw/arm/aspeed_ast2600.c | 49 ++++++++++++++++++++----------------- |
32 | hw/arm/aspeed.c | 3 +++ | 16 | hw/arm/fby35.c | 14 ++++++----- |
33 | hw/arm/aspeed_ast2600.c | 8 ++++---- | 17 | 3 files changed, 37 insertions(+), 30 deletions(-) |
34 | hw/arm/aspeed_soc.c | 8 +++++--- | 18 | |
35 | 5 files changed, 14 insertions(+), 7 deletions(-) | ||
36 | |||
37 | diff --git a/include/hw/arm/aspeed.h b/include/hw/arm/aspeed.h | ||
38 | index XXXXXXX..XXXXXXX 100644 | ||
39 | --- a/include/hw/arm/aspeed.h | ||
40 | +++ b/include/hw/arm/aspeed.h | ||
41 | @@ -XXX,XX +XXX,XX @@ struct AspeedMachineClass { | ||
42 | uint32_t num_cs; | ||
43 | uint32_t macs_mask; | ||
44 | void (*i2c_init)(AspeedMachineState *bmc); | ||
45 | + uint32_t uart_default; | ||
46 | }; | ||
47 | |||
48 | |||
49 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h | 19 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
50 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
51 | --- a/include/hw/arm/aspeed_soc.h | 21 | --- a/include/hw/arm/aspeed_soc.h |
52 | +++ b/include/hw/arm/aspeed_soc.h | 22 | +++ b/include/hw/arm/aspeed_soc.h |
53 | @@ -XXX,XX +XXX,XX @@ struct AspeedSoCState { | 23 | @@ -XXX,XX +XXX,XX @@ struct AspeedSoCState { |
54 | AspeedSDHCIState sdhci; | 24 | DeviceState parent; |
55 | AspeedSDHCIState emmc; | 25 | |
56 | AspeedLPCState lpc; | 26 | ARMCPU cpu[ASPEED_CPUS_NUM]; |
57 | + uint32_t uart_default; | 27 | - A15MPPrivState a7mpcore; |
28 | MemoryRegion *memory; | ||
29 | MemoryRegion *dram_mr; | ||
30 | MemoryRegion dram_container; | ||
31 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2400SoCState, ASPEED2400_SOC) | ||
32 | |||
33 | struct Aspeed2600SoCState { | ||
34 | AspeedSoCState parent; | ||
35 | + | ||
36 | + A15MPPrivState a7mpcore; | ||
37 | + ARMCPU cpu[ASPEED_CPUS_NUM]; /* XXX belong to a7mpcore */ | ||
58 | }; | 38 | }; |
59 | 39 | ||
60 | #define TYPE_ASPEED_SOC "aspeed-soc" | 40 | #define TYPE_ASPEED2600_SOC "aspeed2600-soc" |
61 | diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/hw/arm/aspeed.c | ||
64 | +++ b/hw/arm/aspeed.c | ||
65 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_init(MachineState *machine) | ||
66 | object_property_set_int(OBJECT(&bmc->soc), "hw-prot-key", | ||
67 | ASPEED_SCU_PROT_KEY, &error_abort); | ||
68 | } | ||
69 | + qdev_prop_set_uint32(DEVICE(&bmc->soc), "uart-default", | ||
70 | + amc->uart_default); | ||
71 | qdev_realize(DEVICE(&bmc->soc), NULL, &error_abort); | ||
72 | |||
73 | memory_region_add_subregion(get_system_memory(), | ||
74 | @@ -XXX,XX +XXX,XX @@ static void aspeed_machine_class_init(ObjectClass *oc, void *data) | ||
75 | mc->no_parallel = 1; | ||
76 | mc->default_ram_id = "ram"; | ||
77 | amc->macs_mask = ASPEED_MAC0_ON; | ||
78 | + amc->uart_default = ASPEED_DEV_UART5; | ||
79 | |||
80 | aspeed_machine_class_props_init(oc); | ||
81 | } | ||
82 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c | 41 | diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c |
83 | index XXXXXXX..XXXXXXX 100644 | 42 | index XXXXXXX..XXXXXXX 100644 |
84 | --- a/hw/arm/aspeed_ast2600.c | 43 | --- a/hw/arm/aspeed_ast2600.c |
85 | +++ b/hw/arm/aspeed_ast2600.c | 44 | +++ b/hw/arm/aspeed_ast2600.c |
86 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | 45 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2600_irqmap[] = { |
87 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); | 46 | |
88 | } | 47 | static qemu_irq aspeed_soc_ast2600_get_irq(AspeedSoCState *s, int dev) |
89 | 48 | { | |
90 | - /* UART - attach an 8250 to the IO space as our UART5 */ | 49 | + Aspeed2600SoCState *a = ASPEED2600_SOC(s); |
91 | - serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2, | 50 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); |
92 | - aspeed_soc_get_irq(s, ASPEED_DEV_UART5), | 51 | |
93 | - 38400, serial_hd(0), DEVICE_LITTLE_ENDIAN); | 52 | - return qdev_get_gpio_in(DEVICE(&s->a7mpcore), sc->irqmap[dev]); |
94 | + /* UART - attach an 8250 to the IO space as our UART */ | 53 | + return qdev_get_gpio_in(DEVICE(&a->a7mpcore), sc->irqmap[dev]); |
95 | + serial_mm_init(get_system_memory(), sc->memmap[s->uart_default], 2, | 54 | } |
96 | + aspeed_soc_get_irq(s, s->uart_default), 38400, | 55 | |
97 | + serial_hd(0), DEVICE_LITTLE_ENDIAN); | 56 | static void aspeed_soc_ast2600_init(Object *obj) |
98 | 57 | { | |
99 | /* I2C */ | 58 | + Aspeed2600SoCState *a = ASPEED2600_SOC(obj); |
100 | object_property_set_link(OBJECT(&s->i2c), "dram", OBJECT(s->dram_mr), | 59 | AspeedSoCState *s = ASPEED_SOC(obj); |
101 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c | 60 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); |
61 | int i; | ||
62 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
63 | } | ||
64 | |||
65 | for (i = 0; i < sc->num_cpus; i++) { | ||
66 | - object_initialize_child(obj, "cpu[*]", &s->cpu[i], sc->cpu_type); | ||
67 | + object_initialize_child(obj, "cpu[*]", &a->cpu[i], sc->cpu_type); | ||
68 | } | ||
69 | |||
70 | snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname); | ||
71 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_init(Object *obj) | ||
72 | object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu), | ||
73 | "hw-prot-key"); | ||
74 | |||
75 | - object_initialize_child(obj, "a7mpcore", &s->a7mpcore, | ||
76 | + object_initialize_child(obj, "a7mpcore", &a->a7mpcore, | ||
77 | TYPE_A15MPCORE_PRIV); | ||
78 | |||
79 | object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC); | ||
80 | @@ -XXX,XX +XXX,XX @@ static uint64_t aspeed_calc_affinity(int cpu) | ||
81 | static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
82 | { | ||
83 | int i; | ||
84 | + Aspeed2600SoCState *a = ASPEED2600_SOC(dev); | ||
85 | AspeedSoCState *s = ASPEED_SOC(dev); | ||
86 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
87 | Error *err = NULL; | ||
88 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
89 | /* CPU */ | ||
90 | for (i = 0; i < sc->num_cpus; i++) { | ||
91 | if (sc->num_cpus > 1) { | ||
92 | - object_property_set_int(OBJECT(&s->cpu[i]), "reset-cbar", | ||
93 | + object_property_set_int(OBJECT(&a->cpu[i]), "reset-cbar", | ||
94 | ASPEED_A7MPCORE_ADDR, &error_abort); | ||
95 | } | ||
96 | - object_property_set_int(OBJECT(&s->cpu[i]), "mp-affinity", | ||
97 | + object_property_set_int(OBJECT(&a->cpu[i]), "mp-affinity", | ||
98 | aspeed_calc_affinity(i), &error_abort); | ||
99 | |||
100 | - object_property_set_int(OBJECT(&s->cpu[i]), "cntfrq", 1125000000, | ||
101 | + object_property_set_int(OBJECT(&a->cpu[i]), "cntfrq", 1125000000, | ||
102 | &error_abort); | ||
103 | - object_property_set_bool(OBJECT(&s->cpu[i]), "neon", false, | ||
104 | + object_property_set_bool(OBJECT(&a->cpu[i]), "neon", false, | ||
105 | &error_abort); | ||
106 | - object_property_set_bool(OBJECT(&s->cpu[i]), "vfp-d32", false, | ||
107 | + object_property_set_bool(OBJECT(&a->cpu[i]), "vfp-d32", false, | ||
108 | &error_abort); | ||
109 | - object_property_set_link(OBJECT(&s->cpu[i]), "memory", | ||
110 | + object_property_set_link(OBJECT(&a->cpu[i]), "memory", | ||
111 | OBJECT(s->memory), &error_abort); | ||
112 | |||
113 | - if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) { | ||
114 | + if (!qdev_realize(DEVICE(&a->cpu[i]), NULL, errp)) { | ||
115 | return; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /* A7MPCORE */ | ||
120 | - object_property_set_int(OBJECT(&s->a7mpcore), "num-cpu", sc->num_cpus, | ||
121 | + object_property_set_int(OBJECT(&a->a7mpcore), "num-cpu", sc->num_cpus, | ||
122 | &error_abort); | ||
123 | - object_property_set_int(OBJECT(&s->a7mpcore), "num-irq", | ||
124 | + object_property_set_int(OBJECT(&a->a7mpcore), "num-irq", | ||
125 | ROUND_UP(AST2600_MAX_IRQ + GIC_INTERNAL, 32), | ||
126 | &error_abort); | ||
127 | |||
128 | - sysbus_realize(SYS_BUS_DEVICE(&s->a7mpcore), &error_abort); | ||
129 | - aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->a7mpcore), 0, ASPEED_A7MPCORE_ADDR); | ||
130 | + sysbus_realize(SYS_BUS_DEVICE(&a->a7mpcore), &error_abort); | ||
131 | + aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->a7mpcore), 0, ASPEED_A7MPCORE_ADDR); | ||
132 | |||
133 | for (i = 0; i < sc->num_cpus; i++) { | ||
134 | - SysBusDevice *sbd = SYS_BUS_DEVICE(&s->a7mpcore); | ||
135 | - DeviceState *d = DEVICE(&s->cpu[i]); | ||
136 | + SysBusDevice *sbd = SYS_BUS_DEVICE(&a->a7mpcore); | ||
137 | + DeviceState *d = DEVICE(&a->cpu[i]); | ||
138 | |||
139 | irq = qdev_get_gpio_in(d, ARM_CPU_IRQ); | ||
140 | sysbus_connect_irq(sbd, i, irq); | ||
141 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
142 | } | ||
143 | |||
144 | /* SRAM */ | ||
145 | - sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index); | ||
146 | + sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index); | ||
147 | memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err); | ||
148 | if (err) { | ||
149 | error_propagate(errp, err); | ||
150 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
151 | } | ||
152 | aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i2c), 0, sc->memmap[ASPEED_DEV_I2C]); | ||
153 | for (i = 0; i < ASPEED_I2C_GET_CLASS(&s->i2c)->num_busses; i++) { | ||
154 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
155 | + irq = qdev_get_gpio_in(DEVICE(&a->a7mpcore), | ||
156 | sc->irqmap[ASPEED_DEV_I2C] + i); | ||
157 | /* The AST2600 I2C controller has one IRQ per bus. */ | ||
158 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c.busses[i]), 0, irq); | ||
159 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
160 | * offset 0. | ||
161 | */ | ||
162 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_1, | ||
163 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
164 | + qdev_get_gpio_in(DEVICE(&a->a7mpcore), | ||
165 | sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_1)); | ||
166 | |||
167 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_2, | ||
168 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
169 | + qdev_get_gpio_in(DEVICE(&a->a7mpcore), | ||
170 | sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_2)); | ||
171 | |||
172 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_3, | ||
173 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
174 | + qdev_get_gpio_in(DEVICE(&a->a7mpcore), | ||
175 | sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_3)); | ||
176 | |||
177 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->lpc), 1 + aspeed_lpc_kcs_4, | ||
178 | - qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
179 | + qdev_get_gpio_in(DEVICE(&a->a7mpcore), | ||
180 | sc->irqmap[ASPEED_DEV_KCS] + aspeed_lpc_kcs_4)); | ||
181 | |||
182 | /* HACE */ | ||
183 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) | ||
184 | } | ||
185 | aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->i3c), 0, sc->memmap[ASPEED_DEV_I3C]); | ||
186 | for (i = 0; i < ASPEED_I3C_NR_DEVICES; i++) { | ||
187 | - irq = qdev_get_gpio_in(DEVICE(&s->a7mpcore), | ||
188 | + irq = qdev_get_gpio_in(DEVICE(&a->a7mpcore), | ||
189 | sc->irqmap[ASPEED_DEV_I3C] + i); | ||
190 | /* The AST2600 I3C controller has one IRQ per bus. */ | ||
191 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->i3c.devices[i]), 0, irq); | ||
192 | diff --git a/hw/arm/fby35.c b/hw/arm/fby35.c | ||
102 | index XXXXXXX..XXXXXXX 100644 | 193 | index XXXXXXX..XXXXXXX 100644 |
103 | --- a/hw/arm/aspeed_soc.c | 194 | --- a/hw/arm/fby35.c |
104 | +++ b/hw/arm/aspeed_soc.c | 195 | +++ b/hw/arm/fby35.c |
105 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 196 | @@ -XXX,XX +XXX,XX @@ struct Fby35State { |
106 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->timerctrl), i, irq); | 197 | MemoryRegion bic_memory; |
107 | } | 198 | Clock *bic_sysclk; |
108 | 199 | ||
109 | - /* UART - attach an 8250 to the IO space as our UART5 */ | 200 | - AspeedSoCState bmc; |
110 | - serial_mm_init(get_system_memory(), sc->memmap[ASPEED_DEV_UART5], 2, | 201 | + Aspeed2600SoCState bmc; |
111 | - aspeed_soc_get_irq(s, ASPEED_DEV_UART5), 38400, | 202 | Aspeed10x0SoCState bic; |
112 | + /* UART - attach an 8250 to the IO space as our UART */ | 203 | |
113 | + serial_mm_init(get_system_memory(), sc->memmap[s->uart_default], 2, | 204 | bool mmio_exec; |
114 | + aspeed_soc_get_irq(s, s->uart_default), 38400, | 205 | @@ -XXX,XX +XXX,XX @@ static void fby35_bmc_write_boot_rom(DriveInfo *dinfo, MemoryRegion *mr, |
115 | serial_hd(0), DEVICE_LITTLE_ENDIAN); | 206 | |
116 | 207 | static void fby35_bmc_init(Fby35State *s) | |
117 | /* I2C */ | 208 | { |
118 | @@ -XXX,XX +XXX,XX @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp) | 209 | + AspeedSoCState *soc; |
119 | static Property aspeed_soc_properties[] = { | 210 | + |
120 | DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION, | 211 | object_initialize_child(OBJECT(s), "bmc", &s->bmc, "ast2600-a3"); |
121 | MemoryRegion *), | 212 | + soc = ASPEED_SOC(&s->bmc); |
122 | + DEFINE_PROP_UINT32("uart-default", AspeedSoCState, uart_default, | 213 | |
123 | + ASPEED_DEV_UART5), | 214 | memory_region_init(&s->bmc_memory, OBJECT(&s->bmc), "bmc-memory", |
124 | DEFINE_PROP_END_OF_LIST(), | 215 | UINT64_MAX); |
125 | }; | 216 | @@ -XXX,XX +XXX,XX @@ static void fby35_bmc_init(Fby35State *s) |
126 | 217 | &error_abort); | |
218 | object_property_set_int(OBJECT(&s->bmc), "hw-strap2", 0x00000003, | ||
219 | &error_abort); | ||
220 | - aspeed_soc_uart_set_chr(&s->bmc, ASPEED_DEV_UART5, serial_hd(0)); | ||
221 | + aspeed_soc_uart_set_chr(soc, ASPEED_DEV_UART5, serial_hd(0)); | ||
222 | qdev_realize(DEVICE(&s->bmc), NULL, &error_abort); | ||
223 | |||
224 | - aspeed_board_init_flashes(&s->bmc.fmc, "n25q00", 2, 0); | ||
225 | + aspeed_board_init_flashes(&soc->fmc, "n25q00", 2, 0); | ||
226 | |||
227 | /* Install first FMC flash content as a boot rom. */ | ||
228 | if (!s->mmio_exec) { | ||
229 | DriveInfo *mtd0 = drive_get(IF_MTD, 0, 0); | ||
230 | |||
231 | if (mtd0) { | ||
232 | - AspeedSoCState *bmc = &s->bmc; | ||
233 | - uint64_t rom_size = memory_region_size(&bmc->spi_boot); | ||
234 | + uint64_t rom_size = memory_region_size(&soc->spi_boot); | ||
235 | |||
236 | memory_region_init_rom(&s->bmc_boot_rom, NULL, "aspeed.boot_rom", | ||
237 | rom_size, &error_abort); | ||
238 | - memory_region_add_subregion_overlap(&bmc->spi_boot_container, 0, | ||
239 | + memory_region_add_subregion_overlap(&soc->spi_boot_container, 0, | ||
240 | &s->bmc_boot_rom, 1); | ||
241 | |||
242 | fby35_bmc_write_boot_rom(mtd0, &s->bmc_boot_rom, | ||
127 | -- | 243 | -- |
128 | 2.31.1 | 244 | 2.41.0 |
129 | 245 | ||
130 | 246 | diff view generated by jsdifflib |
1 | From: Andrew Jeffery <andrew@aj.id.au> | 1 | From: Philippe Mathieu-Daudé <philmd@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | There was a bit of a thinko in the state calculation where every odd pin | 3 | The ARM array and VIC peripheral are only used by the |
4 | in was reported in e.g. "pwm0" mode rather than "off". This was the | 4 | 2400 series, remove them from the common AspeedSoCState. |
5 | result of an incorrect bit shift for the 2-bit field representing each | ||
6 | LED state. | ||
7 | 5 | ||
8 | Fixes: a90d8f84674d ("misc/pca9552: Add qom set and get") | 6 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> |
9 | Signed-off-by: Andrew Jeffery <andrew@aj.id.au> | ||
10 | Reviewed-by: Cédric Le Goater <clg@kaod.org> | 7 | Reviewed-by: Cédric Le Goater <clg@kaod.org> |
11 | Message-Id: <20210723043624.348158-1-andrew@aj.id.au> | ||
12 | Signed-off-by: Cédric Le Goater <clg@kaod.org> | 8 | Signed-off-by: Cédric Le Goater <clg@kaod.org> |
13 | --- | 9 | --- |
14 | hw/misc/pca9552.c | 2 +- | 10 | include/hw/arm/aspeed_soc.h | 5 +++-- |
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | 11 | hw/arm/{aspeed_soc.c => aspeed_ast2400.c} | 27 +++++++++++++---------- |
12 | hw/arm/meson.build | 2 +- | ||
13 | 3 files changed, 19 insertions(+), 15 deletions(-) | ||
14 | rename hw/arm/{aspeed_soc.c => aspeed_ast2400.c} (95%) | ||
16 | 15 | ||
17 | diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c | 16 | diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h |
18 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/hw/misc/pca9552.c | 18 | --- a/include/hw/arm/aspeed_soc.h |
20 | +++ b/hw/misc/pca9552.c | 19 | +++ b/include/hw/arm/aspeed_soc.h |
21 | @@ -XXX,XX +XXX,XX @@ static void pca955x_get_led(Object *obj, Visitor *v, const char *name, | 20 | @@ -XXX,XX +XXX,XX @@ |
22 | * reading the INPUTx reg | 21 | struct AspeedSoCState { |
23 | */ | 22 | DeviceState parent; |
24 | reg = PCA9552_LS0 + led / 4; | 23 | |
25 | - state = (pca955x_read(s, reg) >> (led % 8)) & 0x3; | 24 | - ARMCPU cpu[ASPEED_CPUS_NUM]; |
26 | + state = (pca955x_read(s, reg) >> ((led % 4) * 2)) & 0x3; | 25 | MemoryRegion *memory; |
27 | visit_type_str(v, name, (char **)&led_state[state], errp); | 26 | MemoryRegion *dram_mr; |
27 | MemoryRegion dram_container; | ||
28 | MemoryRegion sram; | ||
29 | MemoryRegion spi_boot_container; | ||
30 | MemoryRegion spi_boot; | ||
31 | - AspeedVICState vic; | ||
32 | AspeedRtcState rtc; | ||
33 | AspeedTimerCtrlState timerctrl; | ||
34 | AspeedI2CState i2c; | ||
35 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC) | ||
36 | |||
37 | struct Aspeed2400SoCState { | ||
38 | AspeedSoCState parent; | ||
39 | + | ||
40 | + ARMCPU cpu[ASPEED_CPUS_NUM]; | ||
41 | + AspeedVICState vic; | ||
42 | }; | ||
43 | |||
44 | #define TYPE_ASPEED2400_SOC "aspeed2400-soc" | ||
45 | diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_ast2400.c | ||
46 | similarity index 95% | ||
47 | rename from hw/arm/aspeed_soc.c | ||
48 | rename to hw/arm/aspeed_ast2400.c | ||
49 | index XXXXXXX..XXXXXXX 100644 | ||
50 | --- a/hw/arm/aspeed_soc.c | ||
51 | +++ b/hw/arm/aspeed_ast2400.c | ||
52 | @@ -XXX,XX +XXX,XX @@ static const int aspeed_soc_ast2400_irqmap[] = { | ||
53 | |||
54 | static qemu_irq aspeed_soc_ast2400_get_irq(AspeedSoCState *s, int dev) | ||
55 | { | ||
56 | + Aspeed2400SoCState *a = ASPEED2400_SOC(s); | ||
57 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
58 | |||
59 | - return qdev_get_gpio_in(DEVICE(&s->vic), sc->irqmap[dev]); | ||
60 | + return qdev_get_gpio_in(DEVICE(&a->vic), sc->irqmap[dev]); | ||
28 | } | 61 | } |
29 | 62 | ||
63 | static void aspeed_ast2400_soc_init(Object *obj) | ||
64 | { | ||
65 | + Aspeed2400SoCState *a = ASPEED2400_SOC(obj); | ||
66 | AspeedSoCState *s = ASPEED_SOC(obj); | ||
67 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
68 | int i; | ||
69 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj) | ||
70 | } | ||
71 | |||
72 | for (i = 0; i < sc->num_cpus; i++) { | ||
73 | - object_initialize_child(obj, "cpu[*]", &s->cpu[i], sc->cpu_type); | ||
74 | + object_initialize_child(obj, "cpu[*]", &a->cpu[i], sc->cpu_type); | ||
75 | } | ||
76 | |||
77 | snprintf(typename, sizeof(typename), "aspeed.scu-%s", socname); | ||
78 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj) | ||
79 | object_property_add_alias(obj, "hw-prot-key", OBJECT(&s->scu), | ||
80 | "hw-prot-key"); | ||
81 | |||
82 | - object_initialize_child(obj, "vic", &s->vic, TYPE_ASPEED_VIC); | ||
83 | + object_initialize_child(obj, "vic", &a->vic, TYPE_ASPEED_VIC); | ||
84 | |||
85 | object_initialize_child(obj, "rtc", &s->rtc, TYPE_ASPEED_RTC); | ||
86 | |||
87 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_init(Object *obj) | ||
88 | static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp) | ||
89 | { | ||
90 | int i; | ||
91 | + Aspeed2400SoCState *a = ASPEED2400_SOC(dev); | ||
92 | AspeedSoCState *s = ASPEED_SOC(dev); | ||
93 | AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s); | ||
94 | Error *err = NULL; | ||
95 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp) | ||
96 | |||
97 | /* CPU */ | ||
98 | for (i = 0; i < sc->num_cpus; i++) { | ||
99 | - object_property_set_link(OBJECT(&s->cpu[i]), "memory", | ||
100 | + object_property_set_link(OBJECT(&a->cpu[i]), "memory", | ||
101 | OBJECT(s->memory), &error_abort); | ||
102 | - if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) { | ||
103 | + if (!qdev_realize(DEVICE(&a->cpu[i]), NULL, errp)) { | ||
104 | return; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | /* SRAM */ | ||
109 | - sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&s->cpu[0])->cpu_index); | ||
110 | + sram_name = g_strdup_printf("aspeed.sram.%d", CPU(&a->cpu[0])->cpu_index); | ||
111 | memory_region_init_ram(&s->sram, OBJECT(s), sram_name, sc->sram_size, &err); | ||
112 | if (err) { | ||
113 | error_propagate(errp, err); | ||
114 | @@ -XXX,XX +XXX,XX @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp) | ||
115 | aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->scu), 0, sc->memmap[ASPEED_DEV_SCU]); | ||
116 | |||
117 | /* VIC */ | ||
118 | - if (!sysbus_realize(SYS_BUS_DEVICE(&s->vic), errp)) { | ||
119 | + if (!sysbus_realize(SYS_BUS_DEVICE(&a->vic), errp)) { | ||
120 | return; | ||
121 | } | ||
122 | - aspeed_mmio_map(s, SYS_BUS_DEVICE(&s->vic), 0, sc->memmap[ASPEED_DEV_VIC]); | ||
123 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 0, | ||
124 | - qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ)); | ||
125 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->vic), 1, | ||
126 | - qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); | ||
127 | + aspeed_mmio_map(s, SYS_BUS_DEVICE(&a->vic), 0, sc->memmap[ASPEED_DEV_VIC]); | ||
128 | + sysbus_connect_irq(SYS_BUS_DEVICE(&a->vic), 0, | ||
129 | + qdev_get_gpio_in(DEVICE(&a->cpu), ARM_CPU_IRQ)); | ||
130 | + sysbus_connect_irq(SYS_BUS_DEVICE(&a->vic), 1, | ||
131 | + qdev_get_gpio_in(DEVICE(&a->cpu), ARM_CPU_FIQ)); | ||
132 | |||
133 | /* RTC */ | ||
134 | if (!sysbus_realize(SYS_BUS_DEVICE(&s->rtc), errp)) { | ||
135 | diff --git a/hw/arm/meson.build b/hw/arm/meson.build | ||
136 | index XXXXXXX..XXXXXXX 100644 | ||
137 | --- a/hw/arm/meson.build | ||
138 | +++ b/hw/arm/meson.build | ||
139 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_FSL_IMX25', if_true: files('fsl-imx25.c', 'imx25_pdk.c' | ||
140 | arm_ss.add(when: 'CONFIG_FSL_IMX31', if_true: files('fsl-imx31.c', 'kzm.c')) | ||
141 | arm_ss.add(when: 'CONFIG_FSL_IMX6', if_true: files('fsl-imx6.c')) | ||
142 | arm_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files( | ||
143 | - 'aspeed_soc.c', | ||
144 | 'aspeed.c', | ||
145 | 'aspeed_soc_common.c', | ||
146 | + 'aspeed_ast2400.c', | ||
147 | 'aspeed_ast2600.c', | ||
148 | 'aspeed_ast10x0.c', | ||
149 | 'aspeed_eeprom.c', | ||
30 | -- | 150 | -- |
31 | 2.31.1 | 151 | 2.41.0 |
32 | 152 | ||
33 | 153 | diff view generated by jsdifflib |