1 | First arm pullreq for 7.1. The bulk of this is the qemu_split_irq | 1 | The following changes since commit 8f6330a807f2642dc2a3cdf33347aa28a4c00a87: |
---|---|---|---|
2 | removal. | ||
3 | 2 | ||
4 | I have enough stuff in my to-review queue that I expect to do another | 3 | Merge tag 'pull-maintainer-updates-060324-1' of https://gitlab.com/stsquad/qemu into staging (2024-03-06 16:56:20 +0000) |
5 | pullreq early next week, but 31 patches is enough to not hang on to. | ||
6 | |||
7 | thanks | ||
8 | -- PMM | ||
9 | |||
10 | The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b: | ||
11 | |||
12 | Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700) | ||
13 | 4 | ||
14 | are available in the Git repository at: | 5 | are available in the Git repository at: |
15 | 6 | ||
16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220421 | 7 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20240308 |
17 | 8 | ||
18 | for you to fetch changes up to 5b415dd61bdbf61fb4be0e9f1a7172b8bce682c6: | 9 | for you to fetch changes up to bbf6c6dbead82292a20951eb1204442a6b838de9: |
19 | 10 | ||
20 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs (2022-04-21 11:37:05 +0100) | 11 | target/arm: Move v7m-related code from cpu32.c into a separate file (2024-03-08 14:45:03 +0000) |
21 | 12 | ||
22 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
23 | target-arm queue: | 14 | target-arm queue: |
24 | * hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF | 15 | * Implement FEAT_ECV |
25 | * versal: Add the Cortex-R5s in the Real-Time Processing Unit (RPU) subsystem | 16 | * STM32L4x5: Implement GPIO device |
26 | * versal: model enough of the Clock/Reset Low-power domain (CRL) to allow control of the Cortex-R5s | 17 | * Fix 32-bit SMOPA |
27 | * xlnx-zynqmp: Connect 4 TTC timers | 18 | * Refactor v7m related code from cpu32.c into its own file |
28 | * exynos4210: Refactor GIC/combiner code to stop using qemu_split_irq | 19 | * hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later |
29 | * realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' | ||
30 | * stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' | ||
31 | * hw/core/irq: remove unused 'qemu_irq_split' function | ||
32 | * npcm7xx: use symbolic constants for PWRON STRAP bit fields | ||
33 | * virt: document impact of gic-version on max CPUs | ||
34 | 20 | ||
35 | ---------------------------------------------------------------- | 21 | ---------------------------------------------------------------- |
36 | Edgar E. Iglesias (6): | 22 | Inès Varhol (3): |
37 | timer: cadence_ttc: Break out header file to allow embedding | 23 | hw/gpio: Implement STM32L4x5 GPIO |
38 | hw/arm/xlnx-zynqmp: Connect 4 TTC timers | 24 | hw/arm: Connect STM32L4x5 GPIO to STM32L4x5 SoC |
39 | hw/arm: versal: Create an APU CPU Cluster | 25 | tests/qtest: Add STM32L4x5 GPIO QTest testcase |
40 | hw/arm: versal: Add the Cortex-R5Fs | ||
41 | hw/misc: Add a model of the Xilinx Versal CRL | ||
42 | hw/arm: versal: Connect the CRL | ||
43 | 26 | ||
44 | Hao Wu (2): | 27 | Peter Maydell (9): |
45 | hw/misc: Add PWRON STRAP bit fields in GCR module | 28 | target/arm: Move some register related defines to internals.h |
46 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs | 29 | target/arm: Timer _EL02 registers UNDEF for E2H == 0 |
30 | target/arm: use FIELD macro for CNTHCTL bit definitions | ||
31 | target/arm: Don't allow RES0 CNTHCTL_EL2 bits to be written | ||
32 | target/arm: Implement new FEAT_ECV trap bits | ||
33 | target/arm: Define CNTPCTSS_EL0 and CNTVCTSS_EL0 | ||
34 | target/arm: Implement FEAT_ECV CNTPOFF_EL2 handling | ||
35 | target/arm: Enable FEAT_ECV for 'max' CPU | ||
36 | hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later | ||
47 | 37 | ||
48 | Heinrich Schuchardt (1): | 38 | Richard Henderson (1): |
49 | hw/arm/virt: impact of gic-version on max CPUs | 39 | target/arm: Fix 32-bit SMOPA |
50 | 40 | ||
51 | Peter Maydell (19): | 41 | Thomas Huth (1): |
52 | hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF | 42 | target/arm: Move v7m-related code from cpu32.c into a separate file |
53 | hw/arm/exynos4210: Use TYPE_OR_IRQ instead of custom OR-gate device | ||
54 | hw/intc/exynos4210_gic: Remove unused TYPE_EXYNOS4210_IRQ_GATE | ||
55 | hw/arm/exynos4210: Put a9mpcore device into state struct | ||
56 | hw/arm/exynos4210: Drop int_gic_irq[] from Exynos4210Irq struct | ||
57 | hw/arm/exynos4210: Coalesce board_irqs and irq_table | ||
58 | hw/arm/exynos4210: Fix code style nit in combiner_grp_to_gic_id[] | ||
59 | hw/arm/exynos4210: Move exynos4210_init_board_irqs() into exynos4210.c | ||
60 | hw/arm/exynos4210: Put external GIC into state struct | ||
61 | hw/arm/exynos4210: Drop ext_gic_irq[] from Exynos4210Irq struct | ||
62 | hw/arm/exynos4210: Move exynos4210_combiner_get_gpioin() into exynos4210.c | ||
63 | hw/arm/exynos4210: Delete unused macro definitions | ||
64 | hw/arm/exynos4210: Use TYPE_SPLIT_IRQ in exynos4210_init_board_irqs() | ||
65 | hw/arm/exynos4210: Fill in irq_table[] for internal-combiner-only IRQ lines | ||
66 | hw/arm/exynos4210: Connect MCT_G0 and MCT_G1 to both combiners | ||
67 | hw/arm/exynos4210: Don't connect multiple lines to external GIC inputs | ||
68 | hw/arm/exynos4210: Fold combiner splits into exynos4210_init_board_irqs() | ||
69 | hw/arm/exynos4210: Put combiners into state struct | ||
70 | hw/arm/exynos4210: Drop Exynos4210Irq struct | ||
71 | 43 | ||
72 | Zongyuan Li (3): | 44 | MAINTAINERS | 1 + |
73 | hw/arm/realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' | 45 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
74 | hw/arm/stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' | 46 | docs/system/arm/emulation.rst | 1 + |
75 | hw/core/irq: remove unused 'qemu_irq_split' function | 47 | include/hw/arm/stm32l4x5_soc.h | 2 + |
48 | include/hw/gpio/stm32l4x5_gpio.h | 71 +++++ | ||
49 | include/hw/misc/stm32l4x5_syscfg.h | 3 +- | ||
50 | include/hw/rtc/sun4v-rtc.h | 2 +- | ||
51 | target/arm/cpu-features.h | 10 + | ||
52 | target/arm/cpu.h | 129 +-------- | ||
53 | target/arm/internals.h | 151 ++++++++++ | ||
54 | hw/arm/stm32l4x5_soc.c | 71 ++++- | ||
55 | hw/gpio/stm32l4x5_gpio.c | 477 ++++++++++++++++++++++++++++++++ | ||
56 | hw/misc/stm32l4x5_syscfg.c | 1 + | ||
57 | hw/rtc/sun4v-rtc.c | 2 +- | ||
58 | target/arm/helper.c | 189 ++++++++++++- | ||
59 | target/arm/tcg/cpu-v7m.c | 290 +++++++++++++++++++ | ||
60 | target/arm/tcg/cpu32.c | 261 ------------------ | ||
61 | target/arm/tcg/cpu64.c | 1 + | ||
62 | target/arm/tcg/sme_helper.c | 77 +++--- | ||
63 | tests/qtest/stm32l4x5_gpio-test.c | 551 +++++++++++++++++++++++++++++++++++++ | ||
64 | tests/tcg/aarch64/sme-smopa-1.c | 47 ++++ | ||
65 | tests/tcg/aarch64/sme-smopa-2.c | 54 ++++ | ||
66 | hw/arm/Kconfig | 3 +- | ||
67 | hw/gpio/Kconfig | 3 + | ||
68 | hw/gpio/meson.build | 1 + | ||
69 | hw/gpio/trace-events | 6 + | ||
70 | target/arm/meson.build | 3 + | ||
71 | target/arm/tcg/meson.build | 3 + | ||
72 | target/arm/trace-events | 1 + | ||
73 | tests/qtest/meson.build | 3 +- | ||
74 | tests/tcg/aarch64/Makefile.target | 2 +- | ||
75 | 31 files changed, 1962 insertions(+), 456 deletions(-) | ||
76 | create mode 100644 include/hw/gpio/stm32l4x5_gpio.h | ||
77 | create mode 100644 hw/gpio/stm32l4x5_gpio.c | ||
78 | create mode 100644 target/arm/tcg/cpu-v7m.c | ||
79 | create mode 100644 tests/qtest/stm32l4x5_gpio-test.c | ||
80 | create mode 100644 tests/tcg/aarch64/sme-smopa-1.c | ||
81 | create mode 100644 tests/tcg/aarch64/sme-smopa-2.c | ||
76 | 82 | ||
77 | docs/system/arm/virt.rst | 4 +- | ||
78 | include/hw/arm/exynos4210.h | 50 ++-- | ||
79 | include/hw/arm/xlnx-versal.h | 16 ++ | ||
80 | include/hw/arm/xlnx-zynqmp.h | 4 + | ||
81 | include/hw/intc/exynos4210_combiner.h | 57 +++++ | ||
82 | include/hw/intc/exynos4210_gic.h | 43 ++++ | ||
83 | include/hw/irq.h | 5 - | ||
84 | include/hw/misc/npcm7xx_gcr.h | 30 +++ | ||
85 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++++ | ||
86 | include/hw/timer/cadence_ttc.h | 54 +++++ | ||
87 | hw/arm/exynos4210.c | 430 ++++++++++++++++++++++++++++++---- | ||
88 | hw/arm/npcm7xx_boards.c | 24 +- | ||
89 | hw/arm/realview.c | 33 ++- | ||
90 | hw/arm/stellaris.c | 15 +- | ||
91 | hw/arm/virt.c | 7 + | ||
92 | hw/arm/xlnx-versal-virt.c | 6 +- | ||
93 | hw/arm/xlnx-versal.c | 99 +++++++- | ||
94 | hw/arm/xlnx-zynqmp.c | 22 ++ | ||
95 | hw/core/irq.c | 15 -- | ||
96 | hw/intc/exynos4210_combiner.c | 108 +-------- | ||
97 | hw/intc/exynos4210_gic.c | 344 +-------------------------- | ||
98 | hw/misc/xlnx-versal-crl.c | 421 +++++++++++++++++++++++++++++++++ | ||
99 | hw/timer/cadence_ttc.c | 32 +-- | ||
100 | MAINTAINERS | 2 +- | ||
101 | hw/misc/meson.build | 1 + | ||
102 | 25 files changed, 1457 insertions(+), 600 deletions(-) | ||
103 | create mode 100644 include/hw/intc/exynos4210_combiner.h | ||
104 | create mode 100644 include/hw/intc/exynos4210_gic.h | ||
105 | create mode 100644 include/hw/misc/xlnx-versal-crl.h | ||
106 | create mode 100644 include/hw/timer/cadence_ttc.h | ||
107 | create mode 100644 hw/misc/xlnx-versal-crl.c | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | It's not possible to provide the guest with the Security extensions | ||
2 | (TrustZone) when using KVM or HVF, because the hardware | ||
3 | virtualization extensions don't permit running EL3 guest code. | ||
4 | However, we weren't checking for this combination, with the result | ||
5 | that QEMU would assert if you tried it: | ||
6 | 1 | ||
7 | $ qemu-system-aarch64 -enable-kvm -machine virt,secure=on -cpu host -display none | ||
8 | Unexpected error in object_property_find_err() at ../../qom/object.c:1304: | ||
9 | qemu-system-aarch64: Property 'host-arm-cpu.secure-memory' not found | ||
10 | Aborted | ||
11 | |||
12 | Check for this combination of options and report an error, in the | ||
13 | same way we already do for attempts to give a KVM or HVF guest the | ||
14 | Virtualization or MTE extensions. Now we will report: | ||
15 | |||
16 | qemu-system-aarch64: mach-virt: KVM does not support providing Security extensions (TrustZone) to the guest CPU | ||
17 | |||
18 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/961 | ||
19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
21 | Message-id: 20220404155301.566542-1-peter.maydell@linaro.org | ||
22 | --- | ||
23 | hw/arm/virt.c | 7 +++++++ | ||
24 | 1 file changed, 7 insertions(+) | ||
25 | |||
26 | diff --git a/hw/arm/virt.c b/hw/arm/virt.c | ||
27 | index XXXXXXX..XXXXXXX 100644 | ||
28 | --- a/hw/arm/virt.c | ||
29 | +++ b/hw/arm/virt.c | ||
30 | @@ -XXX,XX +XXX,XX @@ static void machvirt_init(MachineState *machine) | ||
31 | exit(1); | ||
32 | } | ||
33 | |||
34 | + if (vms->secure && (kvm_enabled() || hvf_enabled())) { | ||
35 | + error_report("mach-virt: %s does not support providing " | ||
36 | + "Security extensions (TrustZone) to the guest CPU", | ||
37 | + kvm_enabled() ? "KVM" : "HVF"); | ||
38 | + exit(1); | ||
39 | + } | ||
40 | + | ||
41 | if (vms->virt && (kvm_enabled() || hvf_enabled())) { | ||
42 | error_report("mach-virt: %s does not support providing " | ||
43 | "Virtualization extensions to the guest CPU", | ||
44 | -- | ||
45 | 2.25.1 | diff view generated by jsdifflib |
1 | The combiner_grp_to_gic_id[] array includes the EXT_GIC_ID_MCT_G0 | 1 | cpu.h has a lot of #defines relating to CPU register fields. |
---|---|---|---|
2 | and EXT_GIC_ID_MCT_G1 multiple times. This means that we will | 2 | Most of these aren't actually used outside target/arm code, |
3 | connect multiple IRQs up to the same external GIC input, which | 3 | so there's no point in cluttering up the cpu.h file with them. |
4 | is not permitted. We do the same thing in the code in | 4 | Move some easy ones to internals.h. |
5 | exynos4210_init_board_irqs() because the conditionals selecting | ||
6 | an irq_id in the first loop match multiple interrupt IDs. | ||
7 | |||
8 | Overall we do this for interrupt IDs | ||
9 | (1, 4), (12, 4), (35, 4), (51, 4), (53, 4) for EXT_GIC_ID_MCT_G0 | ||
10 | and | ||
11 | (1, 5), (12, 5), (35, 5), (51, 5), (53, 5) for EXT_GIC_ID_MCT_G1 | ||
12 | |||
13 | These correspond to the cases for the multi-core timer that we are | ||
14 | wiring up to multiple inputs on the combiner in | ||
15 | exynos4210_combiner_get_gpioin(). That code already deals with all | ||
16 | these interrupt IDs being the same input source, so we don't need to | ||
17 | connect the external GIC interrupt for any of them except the first | ||
18 | (1, 4) and (1, 5). Remove the array entries and conditionals which | ||
19 | were incorrectly causing us to wire up extra lines. | ||
20 | |||
21 | This bug didn't cause any visible effects, because we only connect | ||
22 | up a device to the "primary" ID values (1, 4) and (1, 5), so the | ||
23 | extra lines would never be set to a level. | ||
24 | 5 | ||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
26 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
27 | Message-id: 20220404154658.565020-16-peter.maydell@linaro.org | 9 | Message-id: 20240301183219.2424889-2-peter.maydell@linaro.org |
28 | --- | 10 | --- |
29 | include/hw/arm/exynos4210.h | 2 +- | 11 | target/arm/cpu.h | 128 ----------------------------------------- |
30 | hw/arm/exynos4210.c | 12 +++++------- | 12 | target/arm/internals.h | 128 +++++++++++++++++++++++++++++++++++++++++ |
31 | 2 files changed, 6 insertions(+), 8 deletions(-) | 13 | 2 files changed, 128 insertions(+), 128 deletions(-) |
32 | 14 | ||
33 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 15 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
34 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/include/hw/arm/exynos4210.h | 17 | --- a/target/arm/cpu.h |
36 | +++ b/include/hw/arm/exynos4210.h | 18 | +++ b/target/arm/cpu.h |
37 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ typedef struct ARMGenericTimer { |
38 | * one for every non-zero entry in combiner_grp_to_gic_id[]. | 20 | uint64_t ctl; /* Timer Control register */ |
39 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. | 21 | } ARMGenericTimer; |
40 | */ | 22 | |
41 | -#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) | 23 | -#define VTCR_NSW (1u << 29) |
42 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54) | 24 | -#define VTCR_NSA (1u << 30) |
43 | 25 | -#define VSTCR_SW VTCR_NSW | |
44 | typedef struct Exynos4210Irq { | 26 | -#define VSTCR_SA VTCR_NSA |
45 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 27 | - |
46 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 28 | /* Define a maximum sized vector register. |
29 | * For 32-bit, this is a 128-bit NEON/AdvSIMD register. | ||
30 | * For 64-bit, this is a 2048-bit SVE register. | ||
31 | @@ -XXX,XX +XXX,XX @@ void pmu_init(ARMCPU *cpu); | ||
32 | #define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */ | ||
33 | #define SCTLR_TIDCP (1ULL << 63) /* FEAT_TIDCP1 */ | ||
34 | |||
35 | -/* Bit definitions for CPACR (AArch32 only) */ | ||
36 | -FIELD(CPACR, CP10, 20, 2) | ||
37 | -FIELD(CPACR, CP11, 22, 2) | ||
38 | -FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ | ||
39 | -FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ | ||
40 | -FIELD(CPACR, ASEDIS, 31, 1) | ||
41 | - | ||
42 | -/* Bit definitions for CPACR_EL1 (AArch64 only) */ | ||
43 | -FIELD(CPACR_EL1, ZEN, 16, 2) | ||
44 | -FIELD(CPACR_EL1, FPEN, 20, 2) | ||
45 | -FIELD(CPACR_EL1, SMEN, 24, 2) | ||
46 | -FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ | ||
47 | - | ||
48 | -/* Bit definitions for HCPTR (AArch32 only) */ | ||
49 | -FIELD(HCPTR, TCP10, 10, 1) | ||
50 | -FIELD(HCPTR, TCP11, 11, 1) | ||
51 | -FIELD(HCPTR, TASE, 15, 1) | ||
52 | -FIELD(HCPTR, TTA, 20, 1) | ||
53 | -FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ | ||
54 | -FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ | ||
55 | - | ||
56 | -/* Bit definitions for CPTR_EL2 (AArch64 only) */ | ||
57 | -FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ | ||
58 | -FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ | ||
59 | -FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ | ||
60 | -FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ | ||
61 | -FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ | ||
62 | -FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ | ||
63 | -FIELD(CPTR_EL2, TTA, 28, 1) | ||
64 | -FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ | ||
65 | -FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ | ||
66 | - | ||
67 | -/* Bit definitions for CPTR_EL3 (AArch64 only) */ | ||
68 | -FIELD(CPTR_EL3, EZ, 8, 1) | ||
69 | -FIELD(CPTR_EL3, TFP, 10, 1) | ||
70 | -FIELD(CPTR_EL3, ESM, 12, 1) | ||
71 | -FIELD(CPTR_EL3, TTA, 20, 1) | ||
72 | -FIELD(CPTR_EL3, TAM, 30, 1) | ||
73 | -FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
74 | - | ||
75 | -#define MDCR_MTPME (1U << 28) | ||
76 | -#define MDCR_TDCC (1U << 27) | ||
77 | -#define MDCR_HLP (1U << 26) /* MDCR_EL2 */ | ||
78 | -#define MDCR_SCCD (1U << 23) /* MDCR_EL3 */ | ||
79 | -#define MDCR_HCCD (1U << 23) /* MDCR_EL2 */ | ||
80 | -#define MDCR_EPMAD (1U << 21) | ||
81 | -#define MDCR_EDAD (1U << 20) | ||
82 | -#define MDCR_TTRF (1U << 19) | ||
83 | -#define MDCR_STE (1U << 18) /* MDCR_EL3 */ | ||
84 | -#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ | ||
85 | -#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ | ||
86 | -#define MDCR_SDD (1U << 16) | ||
87 | -#define MDCR_SPD (3U << 14) | ||
88 | -#define MDCR_TDRA (1U << 11) | ||
89 | -#define MDCR_TDOSA (1U << 10) | ||
90 | -#define MDCR_TDA (1U << 9) | ||
91 | -#define MDCR_TDE (1U << 8) | ||
92 | -#define MDCR_HPME (1U << 7) | ||
93 | -#define MDCR_TPM (1U << 6) | ||
94 | -#define MDCR_TPMCR (1U << 5) | ||
95 | -#define MDCR_HPMN (0x1fU) | ||
96 | - | ||
97 | -/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ | ||
98 | -#define SDCR_VALID_MASK (MDCR_MTPME | MDCR_TDCC | MDCR_SCCD | \ | ||
99 | - MDCR_EPMAD | MDCR_EDAD | MDCR_TTRF | \ | ||
100 | - MDCR_STE | MDCR_SPME | MDCR_SPD) | ||
101 | - | ||
102 | #define CPSR_M (0x1fU) | ||
103 | #define CPSR_T (1U << 5) | ||
104 | #define CPSR_F (1U << 6) | ||
105 | @@ -XXX,XX +XXX,XX @@ FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
106 | #define XPSR_NZCV CPSR_NZCV | ||
107 | #define XPSR_IT CPSR_IT | ||
108 | |||
109 | -#define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ | ||
110 | -#define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ | ||
111 | -#define TTBCR_PD0 (1U << 4) | ||
112 | -#define TTBCR_PD1 (1U << 5) | ||
113 | -#define TTBCR_EPD0 (1U << 7) | ||
114 | -#define TTBCR_IRGN0 (3U << 8) | ||
115 | -#define TTBCR_ORGN0 (3U << 10) | ||
116 | -#define TTBCR_SH0 (3U << 12) | ||
117 | -#define TTBCR_T1SZ (3U << 16) | ||
118 | -#define TTBCR_A1 (1U << 22) | ||
119 | -#define TTBCR_EPD1 (1U << 23) | ||
120 | -#define TTBCR_IRGN1 (3U << 24) | ||
121 | -#define TTBCR_ORGN1 (3U << 26) | ||
122 | -#define TTBCR_SH1 (1U << 28) | ||
123 | -#define TTBCR_EAE (1U << 31) | ||
124 | - | ||
125 | -FIELD(VTCR, T0SZ, 0, 6) | ||
126 | -FIELD(VTCR, SL0, 6, 2) | ||
127 | -FIELD(VTCR, IRGN0, 8, 2) | ||
128 | -FIELD(VTCR, ORGN0, 10, 2) | ||
129 | -FIELD(VTCR, SH0, 12, 2) | ||
130 | -FIELD(VTCR, TG0, 14, 2) | ||
131 | -FIELD(VTCR, PS, 16, 3) | ||
132 | -FIELD(VTCR, VS, 19, 1) | ||
133 | -FIELD(VTCR, HA, 21, 1) | ||
134 | -FIELD(VTCR, HD, 22, 1) | ||
135 | -FIELD(VTCR, HWU59, 25, 1) | ||
136 | -FIELD(VTCR, HWU60, 26, 1) | ||
137 | -FIELD(VTCR, HWU61, 27, 1) | ||
138 | -FIELD(VTCR, HWU62, 28, 1) | ||
139 | -FIELD(VTCR, NSW, 29, 1) | ||
140 | -FIELD(VTCR, NSA, 30, 1) | ||
141 | -FIELD(VTCR, DS, 32, 1) | ||
142 | -FIELD(VTCR, SL2, 33, 1) | ||
143 | - | ||
144 | /* Bit definitions for ARMv8 SPSR (PSTATE) format. | ||
145 | * Only these are valid when in AArch64 mode; in | ||
146 | * AArch32 mode SPSRs are basically CPSR-format. | ||
147 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | ||
148 | #define HCR_TWEDEN (1ULL << 59) | ||
149 | #define HCR_TWEDEL MAKE_64BIT_MASK(60, 4) | ||
150 | |||
151 | -#define HCRX_ENAS0 (1ULL << 0) | ||
152 | -#define HCRX_ENALS (1ULL << 1) | ||
153 | -#define HCRX_ENASR (1ULL << 2) | ||
154 | -#define HCRX_FNXS (1ULL << 3) | ||
155 | -#define HCRX_FGTNXS (1ULL << 4) | ||
156 | -#define HCRX_SMPME (1ULL << 5) | ||
157 | -#define HCRX_TALLINT (1ULL << 6) | ||
158 | -#define HCRX_VINMI (1ULL << 7) | ||
159 | -#define HCRX_VFNMI (1ULL << 8) | ||
160 | -#define HCRX_CMOW (1ULL << 9) | ||
161 | -#define HCRX_MCE2 (1ULL << 10) | ||
162 | -#define HCRX_MSCEN (1ULL << 11) | ||
163 | - | ||
164 | -#define HPFAR_NS (1ULL << 63) | ||
165 | - | ||
166 | #define SCR_NS (1ULL << 0) | ||
167 | #define SCR_IRQ (1ULL << 1) | ||
168 | #define SCR_FIQ (1ULL << 2) | ||
169 | @@ -XXX,XX +XXX,XX @@ static inline void xpsr_write(CPUARMState *env, uint32_t val, uint32_t mask) | ||
170 | #define SCR_GPF (1ULL << 48) | ||
171 | #define SCR_NSE (1ULL << 62) | ||
172 | |||
173 | -#define HSTR_TTEE (1 << 16) | ||
174 | -#define HSTR_TJDBX (1 << 17) | ||
175 | - | ||
176 | -#define CNTHCTL_CNTVMASK (1 << 18) | ||
177 | -#define CNTHCTL_CNTPMASK (1 << 19) | ||
178 | - | ||
179 | /* Return the current FPSCR value. */ | ||
180 | uint32_t vfp_get_fpscr(CPUARMState *env); | ||
181 | void vfp_set_fpscr(CPUARMState *env, uint32_t val); | ||
182 | diff --git a/target/arm/internals.h b/target/arm/internals.h | ||
47 | index XXXXXXX..XXXXXXX 100644 | 183 | index XXXXXXX..XXXXXXX 100644 |
48 | --- a/hw/arm/exynos4210.c | 184 | --- a/target/arm/internals.h |
49 | +++ b/hw/arm/exynos4210.c | 185 | +++ b/target/arm/internals.h |
50 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | 186 | @@ -XXX,XX +XXX,XX @@ FIELD(DBGWCR, WT, 20, 1) |
51 | /* int combiner group 34 */ | 187 | FIELD(DBGWCR, MASK, 24, 5) |
52 | { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | 188 | FIELD(DBGWCR, SSCE, 29, 1) |
53 | /* int combiner group 35 */ | 189 | |
54 | - { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | 190 | +#define VTCR_NSW (1u << 29) |
55 | + { 0, 0, 0, EXT_GIC_ID_MCT_L1 }, | 191 | +#define VTCR_NSA (1u << 30) |
56 | /* int combiner group 36 */ | 192 | +#define VSTCR_SW VTCR_NSW |
57 | { EXT_GIC_ID_MIXER }, | 193 | +#define VSTCR_SA VTCR_NSA |
58 | /* int combiner group 37 */ | 194 | + |
59 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | 195 | +/* Bit definitions for CPACR (AArch32 only) */ |
60 | /* groups 38-50 */ | 196 | +FIELD(CPACR, CP10, 20, 2) |
61 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | 197 | +FIELD(CPACR, CP11, 22, 2) |
62 | /* int combiner group 51 */ | 198 | +FIELD(CPACR, TRCDIS, 28, 1) /* matches CPACR_EL1.TTA */ |
63 | - { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | 199 | +FIELD(CPACR, D32DIS, 30, 1) /* up to v7; RAZ in v8 */ |
64 | + { EXT_GIC_ID_MCT_L0 }, | 200 | +FIELD(CPACR, ASEDIS, 31, 1) |
65 | /* group 52 */ | 201 | + |
66 | { }, | 202 | +/* Bit definitions for CPACR_EL1 (AArch64 only) */ |
67 | /* int combiner group 53 */ | 203 | +FIELD(CPACR_EL1, ZEN, 16, 2) |
68 | - { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | 204 | +FIELD(CPACR_EL1, FPEN, 20, 2) |
69 | + { EXT_GIC_ID_WDT }, | 205 | +FIELD(CPACR_EL1, SMEN, 24, 2) |
70 | /* groups 54-63 */ | 206 | +FIELD(CPACR_EL1, TTA, 28, 1) /* matches CPACR.TRCDIS */ |
71 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | 207 | + |
72 | }; | 208 | +/* Bit definitions for HCPTR (AArch32 only) */ |
73 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | 209 | +FIELD(HCPTR, TCP10, 10, 1) |
74 | 210 | +FIELD(HCPTR, TCP11, 11, 1) | |
75 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | 211 | +FIELD(HCPTR, TASE, 15, 1) |
76 | irq_id = 0; | 212 | +FIELD(HCPTR, TTA, 20, 1) |
77 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | 213 | +FIELD(HCPTR, TAM, 30, 1) /* matches CPTR_EL2.TAM */ |
78 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | 214 | +FIELD(HCPTR, TCPAC, 31, 1) /* matches CPTR_EL2.TCPAC */ |
79 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4)) { | 215 | + |
80 | /* MCT_G0 is passed to External GIC */ | 216 | +/* Bit definitions for CPTR_EL2 (AArch64 only) */ |
81 | irq_id = EXT_GIC_ID_MCT_G0; | 217 | +FIELD(CPTR_EL2, TZ, 8, 1) /* !E2H */ |
82 | } | 218 | +FIELD(CPTR_EL2, TFP, 10, 1) /* !E2H, matches HCPTR.TCP10 */ |
83 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | 219 | +FIELD(CPTR_EL2, TSM, 12, 1) /* !E2H */ |
84 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | 220 | +FIELD(CPTR_EL2, ZEN, 16, 2) /* E2H */ |
85 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5)) { | 221 | +FIELD(CPTR_EL2, FPEN, 20, 2) /* E2H */ |
86 | /* MCT_G1 is passed to External and GIC */ | 222 | +FIELD(CPTR_EL2, SMEN, 24, 2) /* E2H */ |
87 | irq_id = EXT_GIC_ID_MCT_G1; | 223 | +FIELD(CPTR_EL2, TTA, 28, 1) |
88 | } | 224 | +FIELD(CPTR_EL2, TAM, 30, 1) /* matches HCPTR.TAM */ |
225 | +FIELD(CPTR_EL2, TCPAC, 31, 1) /* matches HCPTR.TCPAC */ | ||
226 | + | ||
227 | +/* Bit definitions for CPTR_EL3 (AArch64 only) */ | ||
228 | +FIELD(CPTR_EL3, EZ, 8, 1) | ||
229 | +FIELD(CPTR_EL3, TFP, 10, 1) | ||
230 | +FIELD(CPTR_EL3, ESM, 12, 1) | ||
231 | +FIELD(CPTR_EL3, TTA, 20, 1) | ||
232 | +FIELD(CPTR_EL3, TAM, 30, 1) | ||
233 | +FIELD(CPTR_EL3, TCPAC, 31, 1) | ||
234 | + | ||
235 | +#define MDCR_MTPME (1U << 28) | ||
236 | +#define MDCR_TDCC (1U << 27) | ||
237 | +#define MDCR_HLP (1U << 26) /* MDCR_EL2 */ | ||
238 | +#define MDCR_SCCD (1U << 23) /* MDCR_EL3 */ | ||
239 | +#define MDCR_HCCD (1U << 23) /* MDCR_EL2 */ | ||
240 | +#define MDCR_EPMAD (1U << 21) | ||
241 | +#define MDCR_EDAD (1U << 20) | ||
242 | +#define MDCR_TTRF (1U << 19) | ||
243 | +#define MDCR_STE (1U << 18) /* MDCR_EL3 */ | ||
244 | +#define MDCR_SPME (1U << 17) /* MDCR_EL3 */ | ||
245 | +#define MDCR_HPMD (1U << 17) /* MDCR_EL2 */ | ||
246 | +#define MDCR_SDD (1U << 16) | ||
247 | +#define MDCR_SPD (3U << 14) | ||
248 | +#define MDCR_TDRA (1U << 11) | ||
249 | +#define MDCR_TDOSA (1U << 10) | ||
250 | +#define MDCR_TDA (1U << 9) | ||
251 | +#define MDCR_TDE (1U << 8) | ||
252 | +#define MDCR_HPME (1U << 7) | ||
253 | +#define MDCR_TPM (1U << 6) | ||
254 | +#define MDCR_TPMCR (1U << 5) | ||
255 | +#define MDCR_HPMN (0x1fU) | ||
256 | + | ||
257 | +/* Not all of the MDCR_EL3 bits are present in the 32-bit SDCR */ | ||
258 | +#define SDCR_VALID_MASK (MDCR_MTPME | MDCR_TDCC | MDCR_SCCD | \ | ||
259 | + MDCR_EPMAD | MDCR_EDAD | MDCR_TTRF | \ | ||
260 | + MDCR_STE | MDCR_SPME | MDCR_SPD) | ||
261 | + | ||
262 | +#define TTBCR_N (7U << 0) /* TTBCR.EAE==0 */ | ||
263 | +#define TTBCR_T0SZ (7U << 0) /* TTBCR.EAE==1 */ | ||
264 | +#define TTBCR_PD0 (1U << 4) | ||
265 | +#define TTBCR_PD1 (1U << 5) | ||
266 | +#define TTBCR_EPD0 (1U << 7) | ||
267 | +#define TTBCR_IRGN0 (3U << 8) | ||
268 | +#define TTBCR_ORGN0 (3U << 10) | ||
269 | +#define TTBCR_SH0 (3U << 12) | ||
270 | +#define TTBCR_T1SZ (3U << 16) | ||
271 | +#define TTBCR_A1 (1U << 22) | ||
272 | +#define TTBCR_EPD1 (1U << 23) | ||
273 | +#define TTBCR_IRGN1 (3U << 24) | ||
274 | +#define TTBCR_ORGN1 (3U << 26) | ||
275 | +#define TTBCR_SH1 (1U << 28) | ||
276 | +#define TTBCR_EAE (1U << 31) | ||
277 | + | ||
278 | +FIELD(VTCR, T0SZ, 0, 6) | ||
279 | +FIELD(VTCR, SL0, 6, 2) | ||
280 | +FIELD(VTCR, IRGN0, 8, 2) | ||
281 | +FIELD(VTCR, ORGN0, 10, 2) | ||
282 | +FIELD(VTCR, SH0, 12, 2) | ||
283 | +FIELD(VTCR, TG0, 14, 2) | ||
284 | +FIELD(VTCR, PS, 16, 3) | ||
285 | +FIELD(VTCR, VS, 19, 1) | ||
286 | +FIELD(VTCR, HA, 21, 1) | ||
287 | +FIELD(VTCR, HD, 22, 1) | ||
288 | +FIELD(VTCR, HWU59, 25, 1) | ||
289 | +FIELD(VTCR, HWU60, 26, 1) | ||
290 | +FIELD(VTCR, HWU61, 27, 1) | ||
291 | +FIELD(VTCR, HWU62, 28, 1) | ||
292 | +FIELD(VTCR, NSW, 29, 1) | ||
293 | +FIELD(VTCR, NSA, 30, 1) | ||
294 | +FIELD(VTCR, DS, 32, 1) | ||
295 | +FIELD(VTCR, SL2, 33, 1) | ||
296 | + | ||
297 | +#define HCRX_ENAS0 (1ULL << 0) | ||
298 | +#define HCRX_ENALS (1ULL << 1) | ||
299 | +#define HCRX_ENASR (1ULL << 2) | ||
300 | +#define HCRX_FNXS (1ULL << 3) | ||
301 | +#define HCRX_FGTNXS (1ULL << 4) | ||
302 | +#define HCRX_SMPME (1ULL << 5) | ||
303 | +#define HCRX_TALLINT (1ULL << 6) | ||
304 | +#define HCRX_VINMI (1ULL << 7) | ||
305 | +#define HCRX_VFNMI (1ULL << 8) | ||
306 | +#define HCRX_CMOW (1ULL << 9) | ||
307 | +#define HCRX_MCE2 (1ULL << 10) | ||
308 | +#define HCRX_MSCEN (1ULL << 11) | ||
309 | + | ||
310 | +#define HPFAR_NS (1ULL << 63) | ||
311 | + | ||
312 | +#define HSTR_TTEE (1 << 16) | ||
313 | +#define HSTR_TJDBX (1 << 17) | ||
314 | + | ||
315 | +#define CNTHCTL_CNTVMASK (1 << 18) | ||
316 | +#define CNTHCTL_CNTPMASK (1 << 19) | ||
317 | + | ||
318 | /* We use a few fake FSR values for internal purposes in M profile. | ||
319 | * M profile cores don't have A/R format FSRs, but currently our | ||
320 | * get_phys_addr() code assumes A/R profile and reports failures via | ||
89 | -- | 321 | -- |
90 | 2.25.1 | 322 | 2.34.1 |
323 | |||
324 | diff view generated by jsdifflib |
1 | At this point, the function exynos4210_init_board_irqs() splits input | 1 | The timer _EL02 registers should UNDEF for invalid accesses from EL2 |
---|---|---|---|
2 | IRQ lines to connect them to the input combiner, output combiner and | 2 | or EL3 when HCR_EL2.E2H == 0, not take a cp access trap. We were |
3 | external GIC. The function exynos4210_combiner_get_gpioin() splits | 3 | delivering the exception to EL2 with the wrong syndrome. |
4 | some of the combiner input lines further to connect them to multiple | ||
5 | different inputs on the combiner. | ||
6 | |||
7 | Because (unlike qemu_irq_split()) the TYPE_SPLIT_IRQ device has a | ||
8 | configurable number of outputs, we can do all this in one place, by | ||
9 | making exynos4210_init_board_irqs() add extra outputs to the splitter | ||
10 | device when it must be connected to more than one input on each | ||
11 | combiner. | ||
12 | |||
13 | We do this with a new data structure, the combinermap, which is an | ||
14 | array each of whose elements is a list of the interrupt IDs on the | ||
15 | combiner which must be tied together. As we loop through each | ||
16 | interrupt ID, if we find that it is the first one in one of these | ||
17 | lists, we configure the splitter device with eonugh extra outputs and | ||
18 | wire them up to the other interrupt IDs in the list. | ||
19 | |||
20 | Conveniently, for all the cases where this is necessary, the | ||
21 | lowest-numbered interrupt ID in each group is in the range of the | ||
22 | external combiner, so we only need to code for this in the first of | ||
23 | the two loops in exynos4210_init_board_irqs(). | ||
24 | |||
25 | The old code in exynos4210_combiner_get_gpioin() which is being | ||
26 | deleted here had several problems which don't exist in the new code | ||
27 | in its handling of the multi-core timer interrupts: | ||
28 | (1) the case labels specified bits 4 ... 8, but bit '8' doesn't | ||
29 | exist; these should have been 4 ... 7 | ||
30 | (2) it used the input irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)] | ||
31 | multiple times as the input of several different splitters, | ||
32 | which isn't allowed | ||
33 | (3) in an apparent cut-and-paste error, the cases for all the | ||
34 | multi-core timer inputs used "bit + 4" even though the | ||
35 | bit range for the case was (intended to be) 4 ... 7, which | ||
36 | meant it was looking at non-existent bits 8 ... 11. | ||
37 | None of these exist in the new code. | ||
38 | 4 | ||
39 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
40 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
41 | Message-id: 20220404154658.565020-17-peter.maydell@linaro.org | 7 | Message-id: 20240301183219.2424889-3-peter.maydell@linaro.org |
42 | --- | 8 | --- |
43 | include/hw/arm/exynos4210.h | 6 +- | 9 | target/arm/helper.c | 2 +- |
44 | hw/arm/exynos4210.c | 178 +++++++++++++++++++++++------------- | 10 | 1 file changed, 1 insertion(+), 1 deletion(-) |
45 | 2 files changed, 119 insertions(+), 65 deletions(-) | ||
46 | 11 | ||
47 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 12 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
48 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
49 | --- a/include/hw/arm/exynos4210.h | 14 | --- a/target/arm/helper.c |
50 | +++ b/include/hw/arm/exynos4210.h | 15 | +++ b/target/arm/helper.c |
51 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, |
52 | 17 | return CP_ACCESS_OK; | |
53 | /* | ||
54 | * We need one splitter for every external combiner input, plus | ||
55 | - * one for every non-zero entry in combiner_grp_to_gic_id[]. | ||
56 | + * one for every non-zero entry in combiner_grp_to_gic_id[], | ||
57 | + * minus one for every external combiner ID in second or later | ||
58 | + * places in a combinermap[] line. | ||
59 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. | ||
60 | */ | ||
61 | -#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54) | ||
62 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38) | ||
63 | |||
64 | typedef struct Exynos4210Irq { | ||
65 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
66 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
67 | index XXXXXXX..XXXXXXX 100644 | ||
68 | --- a/hw/arm/exynos4210.c | ||
69 | +++ b/hw/arm/exynos4210.c | ||
70 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
71 | #define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | ||
72 | ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | ||
73 | |||
74 | +/* | ||
75 | + * Some interrupt lines go to multiple combiner inputs. | ||
76 | + * This data structure defines those: each array element is | ||
77 | + * a list of combiner inputs which are connected together; | ||
78 | + * the one with the smallest interrupt ID value must be first. | ||
79 | + * As with combiner_grp_to_gic_id[], we rely on (0, 0) not being | ||
80 | + * wired to anything so we can use 0 as a terminator. | ||
81 | + */ | ||
82 | +#define IRQNO(G, B) EXYNOS4210_COMBINER_GET_IRQ_NUM(G, B) | ||
83 | +#define IRQNONE 0 | ||
84 | + | ||
85 | +#define COMBINERMAP_SIZE 16 | ||
86 | + | ||
87 | +static const int combinermap[COMBINERMAP_SIZE][6] = { | ||
88 | + /* MDNIE_LCD1 */ | ||
89 | + { IRQNO(0, 4), IRQNO(1, 0), IRQNONE }, | ||
90 | + { IRQNO(0, 5), IRQNO(1, 1), IRQNONE }, | ||
91 | + { IRQNO(0, 6), IRQNO(1, 2), IRQNONE }, | ||
92 | + { IRQNO(0, 7), IRQNO(1, 3), IRQNONE }, | ||
93 | + /* TMU */ | ||
94 | + { IRQNO(2, 4), IRQNO(3, 4), IRQNONE }, | ||
95 | + { IRQNO(2, 5), IRQNO(3, 5), IRQNONE }, | ||
96 | + { IRQNO(2, 6), IRQNO(3, 6), IRQNONE }, | ||
97 | + { IRQNO(2, 7), IRQNO(3, 7), IRQNONE }, | ||
98 | + /* LCD1 */ | ||
99 | + { IRQNO(11, 4), IRQNO(12, 0), IRQNONE }, | ||
100 | + { IRQNO(11, 5), IRQNO(12, 1), IRQNONE }, | ||
101 | + { IRQNO(11, 6), IRQNO(12, 2), IRQNONE }, | ||
102 | + { IRQNO(11, 7), IRQNO(12, 3), IRQNONE }, | ||
103 | + /* Multi-core timer */ | ||
104 | + { IRQNO(1, 4), IRQNO(12, 4), IRQNO(35, 4), IRQNO(51, 4), IRQNO(53, 4), IRQNONE }, | ||
105 | + { IRQNO(1, 5), IRQNO(12, 5), IRQNO(35, 5), IRQNO(51, 5), IRQNO(53, 5), IRQNONE }, | ||
106 | + { IRQNO(1, 6), IRQNO(12, 6), IRQNO(35, 6), IRQNO(51, 6), IRQNO(53, 6), IRQNONE }, | ||
107 | + { IRQNO(1, 7), IRQNO(12, 7), IRQNO(35, 7), IRQNO(51, 7), IRQNO(53, 7), IRQNONE }, | ||
108 | +}; | ||
109 | + | ||
110 | +#undef IRQNO | ||
111 | + | ||
112 | +static const int *combinermap_entry(int irq) | ||
113 | +{ | ||
114 | + /* | ||
115 | + * If the interrupt number passed in is the first entry in some | ||
116 | + * line of the combinermap, return a pointer to that line; | ||
117 | + * otherwise return NULL. | ||
118 | + */ | ||
119 | + int i; | ||
120 | + for (i = 0; i < COMBINERMAP_SIZE; i++) { | ||
121 | + if (combinermap[i][0] == irq) { | ||
122 | + return combinermap[i]; | ||
123 | + } | ||
124 | + } | ||
125 | + return NULL; | ||
126 | +} | ||
127 | + | ||
128 | +static int mapline_size(const int *mapline) | ||
129 | +{ | ||
130 | + /* Return number of entries in this mapline in total */ | ||
131 | + int i = 0; | ||
132 | + | ||
133 | + if (!mapline) { | ||
134 | + /* Not in the map? IRQ goes to exactly one combiner input */ | ||
135 | + return 1; | ||
136 | + } | ||
137 | + while (*mapline != IRQNONE) { | ||
138 | + mapline++; | ||
139 | + i++; | ||
140 | + } | ||
141 | + return i; | ||
142 | +} | ||
143 | + | ||
144 | /* | ||
145 | * Initialize board IRQs. | ||
146 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
147 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
148 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
149 | int splitcount = 0; | ||
150 | DeviceState *splitter; | ||
151 | + const int *mapline; | ||
152 | + int numlines, splitin, in; | ||
153 | |||
154 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
155 | irq_id = 0; | ||
156 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
157 | irq_id = EXT_GIC_ID_MCT_G1; | ||
158 | } | ||
159 | |||
160 | + if (s->irq_table[n]) { | ||
161 | + /* | ||
162 | + * This must be some non-first entry in a combinermap line, | ||
163 | + * and we've already filled it in. | ||
164 | + */ | ||
165 | + continue; | ||
166 | + } | ||
167 | + mapline = combinermap_entry(n); | ||
168 | + /* | ||
169 | + * We need to connect the IRQ to multiple inputs on both combiners | ||
170 | + * and possibly also to the external GIC. | ||
171 | + */ | ||
172 | + numlines = 2 * mapline_size(mapline); | ||
173 | + if (irq_id) { | ||
174 | + numlines++; | ||
175 | + } | ||
176 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
177 | splitter = DEVICE(&s->splitter[splitcount]); | ||
178 | - qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2); | ||
179 | + qdev_prop_set_uint16(splitter, "num-lines", numlines); | ||
180 | qdev_realize(splitter, NULL, &error_abort); | ||
181 | splitcount++; | ||
182 | - s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
183 | - qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
184 | - qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
185 | + | ||
186 | + in = n; | ||
187 | + splitin = 0; | ||
188 | + for (;;) { | ||
189 | + s->irq_table[in] = qdev_get_gpio_in(splitter, 0); | ||
190 | + qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]); | ||
191 | + qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]); | ||
192 | + splitin += 2; | ||
193 | + if (!mapline) { | ||
194 | + break; | ||
195 | + } | ||
196 | + mapline++; | ||
197 | + in = *mapline; | ||
198 | + if (in == IRQNONE) { | ||
199 | + break; | ||
200 | + } | ||
201 | + } | ||
202 | if (irq_id) { | ||
203 | - qdev_connect_gpio_out(splitter, 2, | ||
204 | + qdev_connect_gpio_out(splitter, splitin, | ||
205 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
206 | } | ||
207 | } | 18 | } |
208 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | 19 | if (!(arm_hcr_el2_eff(env) & HCR_E2H)) { |
209 | irq_id = combiner_grp_to_gic_id[grp - | 20 | - return CP_ACCESS_TRAP; |
210 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | 21 | + return CP_ACCESS_TRAP_UNCATEGORIZED; |
211 | |||
212 | + if (s->irq_table[n]) { | ||
213 | + /* | ||
214 | + * This must be some non-first entry in a combinermap line, | ||
215 | + * and we've already filled it in. | ||
216 | + */ | ||
217 | + continue; | ||
218 | + } | ||
219 | + | ||
220 | if (irq_id) { | ||
221 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
222 | splitter = DEVICE(&s->splitter[splitcount]); | ||
223 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
224 | DeviceState *dev, int ext) | ||
225 | { | ||
226 | int n; | ||
227 | - int bit; | ||
228 | int max; | ||
229 | qemu_irq *irq; | ||
230 | |||
231 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
232 | EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
233 | irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
234 | |||
235 | - /* | ||
236 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, | ||
237 | - * so let split them. | ||
238 | - */ | ||
239 | for (n = 0; n < max; n++) { | ||
240 | - | ||
241 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
242 | - | ||
243 | - switch (n) { | ||
244 | - /* MDNIE_LCD1 INTG1 */ | ||
245 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | ||
246 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | ||
247 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
248 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
249 | - continue; | ||
250 | - | ||
251 | - /* TMU INTG3 */ | ||
252 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
253 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
254 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
255 | - continue; | ||
256 | - | ||
257 | - /* LCD1 INTG12 */ | ||
258 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
259 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
260 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
261 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
262 | - continue; | ||
263 | - | ||
264 | - /* Multi-Core Timer INTG12 */ | ||
265 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
266 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
267 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
268 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
269 | - continue; | ||
270 | - | ||
271 | - /* Multi-Core Timer INTG35 */ | ||
272 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
273 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
274 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
275 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
276 | - continue; | ||
277 | - | ||
278 | - /* Multi-Core Timer INTG51 */ | ||
279 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
280 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
281 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
282 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
283 | - continue; | ||
284 | - | ||
285 | - /* Multi-Core Timer INTG53 */ | ||
286 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
287 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
288 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
289 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
290 | - continue; | ||
291 | - } | ||
292 | - | ||
293 | irq[n] = qdev_get_gpio_in(dev, n); | ||
294 | } | 22 | } |
23 | return CP_ACCESS_OK; | ||
295 | } | 24 | } |
296 | -- | 25 | -- |
297 | 2.25.1 | 26 | 2.34.1 | diff view generated by jsdifflib |
1 | The exynos4210 code currently has two very similar arrays of IRQs: | 1 | We prefer the FIELD macro over ad-hoc #defines for register bits; |
---|---|---|---|
2 | 2 | switch CNTHCTL to that style before we add any more bits. | |
3 | * board_irqs is a field of the Exynos4210Irq struct which is filled | ||
4 | in by exynos4210_init_board_irqs() with the appropriate qemu_irqs | ||
5 | for each IRQ the board/SoC can assert | ||
6 | * irq_table is a set of qemu_irqs pointed to from the | ||
7 | Exynos4210State struct. It's allocated in exynos4210_init_irq, | ||
8 | and the only behaviour these irqs have is that they pass on the | ||
9 | level to the equivalent board_irqs[] irq | ||
10 | |||
11 | The extra indirection through irq_table is unnecessary, so coalesce | ||
12 | these into a single irq_table[] array as a direct field in | ||
13 | Exynos4210State which exynos4210_init_board_irqs() fills in. | ||
14 | 3 | ||
15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
17 | Message-id: 20220404154658.565020-6-peter.maydell@linaro.org | 7 | Message-id: 20240301183219.2424889-4-peter.maydell@linaro.org |
18 | --- | 8 | --- |
19 | include/hw/arm/exynos4210.h | 8 ++------ | 9 | target/arm/internals.h | 27 +++++++++++++++++++++++++-- |
20 | hw/arm/exynos4210.c | 6 +----- | 10 | target/arm/helper.c | 9 ++++----- |
21 | hw/intc/exynos4210_gic.c | 32 ++++++++------------------------ | 11 | 2 files changed, 29 insertions(+), 7 deletions(-) |
22 | 3 files changed, 11 insertions(+), 35 deletions(-) | ||
23 | 12 | ||
24 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 13 | diff --git a/target/arm/internals.h b/target/arm/internals.h |
25 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
26 | --- a/include/hw/arm/exynos4210.h | 15 | --- a/target/arm/internals.h |
27 | +++ b/include/hw/arm/exynos4210.h | 16 | +++ b/target/arm/internals.h |
28 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210Irq { | 17 | @@ -XXX,XX +XXX,XX @@ FIELD(VTCR, SL2, 33, 1) |
29 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 18 | #define HSTR_TTEE (1 << 16) |
30 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | 19 | #define HSTR_TJDBX (1 << 17) |
31 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | 20 | |
32 | - qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 21 | -#define CNTHCTL_CNTVMASK (1 << 18) |
33 | } Exynos4210Irq; | 22 | -#define CNTHCTL_CNTPMASK (1 << 19) |
34 | 23 | +/* | |
35 | struct Exynos4210State { | 24 | + * Depending on the value of HCR_EL2.E2H, bits 0 and 1 |
36 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | 25 | + * have different bit definitions, and EL1PCTEN might be |
37 | /*< public >*/ | 26 | + * bit 0 or bit 10. We use _E2H1 and _E2H0 suffixes to |
38 | ARMCPU *cpu[EXYNOS4210_NCPUS]; | 27 | + * disambiguate if necessary. |
39 | Exynos4210Irq irqs; | 28 | + */ |
40 | - qemu_irq *irq_table; | 29 | +FIELD(CNTHCTL, EL0PCTEN_E2H1, 0, 1) |
41 | + qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 30 | +FIELD(CNTHCTL, EL0VCTEN_E2H1, 1, 1) |
42 | 31 | +FIELD(CNTHCTL, EL1PCTEN_E2H0, 0, 1) | |
43 | MemoryRegion chipid_mem; | 32 | +FIELD(CNTHCTL, EL1PCEN_E2H0, 1, 1) |
44 | MemoryRegion iram_mem; | 33 | +FIELD(CNTHCTL, EVNTEN, 2, 1) |
45 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) | 34 | +FIELD(CNTHCTL, EVNTDIR, 3, 1) |
46 | void exynos4210_write_secondary(ARMCPU *cpu, | 35 | +FIELD(CNTHCTL, EVNTI, 4, 4) |
47 | const struct arm_boot_info *info); | 36 | +FIELD(CNTHCTL, EL0VTEN, 8, 1) |
48 | 37 | +FIELD(CNTHCTL, EL0PTEN, 9, 1) | |
49 | -/* Initialize exynos4210 IRQ subsystem stub */ | 38 | +FIELD(CNTHCTL, EL1PCTEN_E2H1, 10, 1) |
50 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *env); | 39 | +FIELD(CNTHCTL, EL1PTEN, 11, 1) |
40 | +FIELD(CNTHCTL, ECV, 12, 1) | ||
41 | +FIELD(CNTHCTL, EL1TVT, 13, 1) | ||
42 | +FIELD(CNTHCTL, EL1TVCT, 14, 1) | ||
43 | +FIELD(CNTHCTL, EL1NVPCT, 15, 1) | ||
44 | +FIELD(CNTHCTL, EL1NVVCT, 16, 1) | ||
45 | +FIELD(CNTHCTL, EVNTIS, 17, 1) | ||
46 | +FIELD(CNTHCTL, CNTVMASK, 18, 1) | ||
47 | +FIELD(CNTHCTL, CNTPMASK, 19, 1) | ||
48 | |||
49 | /* We use a few fake FSR values for internal purposes in M profile. | ||
50 | * M profile cores don't have A/R format FSRs, but currently our | ||
51 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
52 | index XXXXXXX..XXXXXXX 100644 | ||
53 | --- a/target/arm/helper.c | ||
54 | +++ b/target/arm/helper.c | ||
55 | @@ -XXX,XX +XXX,XX @@ static void gt_update_irq(ARMCPU *cpu, int timeridx) | ||
56 | * It is RES0 in Secure and NonSecure state. | ||
57 | */ | ||
58 | if ((ss == ARMSS_Root || ss == ARMSS_Realm) && | ||
59 | - ((timeridx == GTIMER_VIRT && (cnthctl & CNTHCTL_CNTVMASK)) || | ||
60 | - (timeridx == GTIMER_PHYS && (cnthctl & CNTHCTL_CNTPMASK)))) { | ||
61 | + ((timeridx == GTIMER_VIRT && (cnthctl & R_CNTHCTL_CNTVMASK_MASK)) || | ||
62 | + (timeridx == GTIMER_PHYS && (cnthctl & R_CNTHCTL_CNTPMASK_MASK)))) { | ||
63 | irqstate = 0; | ||
64 | } | ||
65 | |||
66 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
67 | { | ||
68 | ARMCPU *cpu = env_archcpu(env); | ||
69 | uint32_t oldval = env->cp15.cnthctl_el2; | ||
51 | - | 70 | - |
52 | /* Initialize board IRQs. | 71 | raw_write(env, ri, value); |
53 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ | 72 | |
54 | -void exynos4210_init_board_irqs(Exynos4210Irq *s); | 73 | - if ((oldval ^ value) & CNTHCTL_CNTVMASK) { |
55 | +void exynos4210_init_board_irqs(Exynos4210State *s); | 74 | + if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) { |
56 | 75 | gt_update_irq(cpu, GTIMER_VIRT); | |
57 | /* Get IRQ number from exynos4210 IRQ subsystem stub. | 76 | - } else if ((oldval ^ value) & CNTHCTL_CNTPMASK) { |
58 | * To identify IRQ source use internal combiner group and bit number | 77 | + } else if ((oldval ^ value) & R_CNTHCTL_CNTPMASK_MASK) { |
59 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 78 | gt_update_irq(cpu, GTIMER_PHYS); |
60 | index XXXXXXX..XXXXXXX 100644 | ||
61 | --- a/hw/arm/exynos4210.c | ||
62 | +++ b/hw/arm/exynos4210.c | ||
63 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
64 | qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); | ||
65 | } | ||
66 | |||
67 | - /*** IRQs ***/ | ||
68 | - | ||
69 | - s->irq_table = exynos4210_init_irq(&s->irqs); | ||
70 | - | ||
71 | /* IRQ Gate */ | ||
72 | for (i = 0; i < EXYNOS4210_NCPUS; i++) { | ||
73 | DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]); | ||
74 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
75 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
76 | |||
77 | /* Initialize board IRQs. */ | ||
78 | - exynos4210_init_board_irqs(&s->irqs); | ||
79 | + exynos4210_init_board_irqs(s); | ||
80 | |||
81 | /*** Memory ***/ | ||
82 | |||
83 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
84 | index XXXXXXX..XXXXXXX 100644 | ||
85 | --- a/hw/intc/exynos4210_gic.c | ||
86 | +++ b/hw/intc/exynos4210_gic.c | ||
87 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
88 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
89 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
90 | |||
91 | -static void exynos4210_irq_handler(void *opaque, int irq, int level) | ||
92 | -{ | ||
93 | - Exynos4210Irq *s = (Exynos4210Irq *)opaque; | ||
94 | - | ||
95 | - /* Bypass */ | ||
96 | - qemu_set_irq(s->board_irqs[irq], level); | ||
97 | -} | ||
98 | - | ||
99 | -/* | ||
100 | - * Initialize exynos4210 IRQ subsystem stub. | ||
101 | - */ | ||
102 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *s) | ||
103 | -{ | ||
104 | - return qemu_allocate_irqs(exynos4210_irq_handler, s, | ||
105 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ); | ||
106 | -} | ||
107 | - | ||
108 | /* | ||
109 | * Initialize board IRQs. | ||
110 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
111 | */ | ||
112 | -void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
113 | +void exynos4210_init_board_irqs(Exynos4210State *s) | ||
114 | { | ||
115 | uint32_t grp, bit, irq_id, n; | ||
116 | + Exynos4210Irq *is = &s->irqs; | ||
117 | |||
118 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
119 | irq_id = 0; | ||
120 | @@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
121 | irq_id = EXT_GIC_ID_MCT_G1; | ||
122 | } | ||
123 | if (irq_id) { | ||
124 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
125 | - s->ext_gic_irq[irq_id-32]); | ||
126 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
127 | + is->ext_gic_irq[irq_id - 32]); | ||
128 | } else { | ||
129 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
130 | - s->ext_combiner_irq[n]); | ||
131 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
132 | + is->ext_combiner_irq[n]); | ||
133 | } | ||
134 | } | ||
135 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
136 | @@ -XXX,XX +XXX,XX @@ void exynos4210_init_board_irqs(Exynos4210Irq *s) | ||
137 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
138 | |||
139 | if (irq_id) { | ||
140 | - s->board_irqs[n] = qemu_irq_split(s->int_combiner_irq[n], | ||
141 | - s->ext_gic_irq[irq_id-32]); | ||
142 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
143 | + is->ext_gic_irq[irq_id - 32]); | ||
144 | } | ||
145 | } | 79 | } |
146 | } | 80 | } |
147 | -- | 81 | -- |
148 | 2.25.1 | 82 | 2.34.1 |
83 | |||
84 | diff view generated by jsdifflib |
1 | In exynos4210_init_board_irqs(), use the TYPE_SPLIT_IRQ device | 1 | Don't allow the guest to write CNTHCTL_EL2 bits which don't exist. |
---|---|---|---|
2 | instead of qemu_irq_split(). | 2 | This is not strictly architecturally required, but it is how we've |
3 | tended to implement registers more recently. | ||
4 | |||
5 | In particular, bits [19:18] are only present with FEAT_RME, | ||
6 | and bits [17:12] will only be present with FEAT_ECV. | ||
3 | 7 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 9 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
6 | Message-id: 20220404154658.565020-13-peter.maydell@linaro.org | 10 | Message-id: 20240301183219.2424889-5-peter.maydell@linaro.org |
7 | --- | 11 | --- |
8 | include/hw/arm/exynos4210.h | 9 ++++++++ | 12 | target/arm/helper.c | 18 ++++++++++++++++++ |
9 | hw/arm/exynos4210.c | 41 +++++++++++++++++++++++++++++-------- | 13 | 1 file changed, 18 insertions(+) |
10 | 2 files changed, 42 insertions(+), 8 deletions(-) | ||
11 | 14 | ||
12 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 15 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
13 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
14 | --- a/include/hw/arm/exynos4210.h | 17 | --- a/target/arm/helper.c |
15 | +++ b/include/hw/arm/exynos4210.h | 18 | +++ b/target/arm/helper.c |
16 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
17 | #include "hw/sysbus.h" | 20 | { |
18 | #include "hw/cpu/a9mpcore.h" | 21 | ARMCPU *cpu = env_archcpu(env); |
19 | #include "hw/intc/exynos4210_gic.h" | 22 | uint32_t oldval = env->cp15.cnthctl_el2; |
20 | +#include "hw/core/split-irq.h" | 23 | + uint32_t valid_mask = |
21 | #include "target/arm/cpu-qom.h" | 24 | + R_CNTHCTL_EL0PCTEN_E2H1_MASK | |
22 | #include "qom/object.h" | 25 | + R_CNTHCTL_EL0VCTEN_E2H1_MASK | |
23 | 26 | + R_CNTHCTL_EVNTEN_MASK | | |
24 | @@ -XXX,XX +XXX,XX @@ | 27 | + R_CNTHCTL_EVNTDIR_MASK | |
25 | 28 | + R_CNTHCTL_EVNTI_MASK | | |
26 | #define EXYNOS4210_NUM_DMA 3 | 29 | + R_CNTHCTL_EL0VTEN_MASK | |
27 | 30 | + R_CNTHCTL_EL0PTEN_MASK | | |
28 | +/* | 31 | + R_CNTHCTL_EL1PCTEN_E2H1_MASK | |
29 | + * We need one splitter for every external combiner input, plus | 32 | + R_CNTHCTL_EL1PTEN_MASK; |
30 | + * one for every non-zero entry in combiner_grp_to_gic_id[]. | ||
31 | + * We'll assert in exynos4210_init_board_irqs() if this is wrong. | ||
32 | + */ | ||
33 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) | ||
34 | + | 33 | + |
35 | typedef struct Exynos4210Irq { | 34 | + if (cpu_isar_feature(aa64_rme, cpu)) { |
36 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 35 | + valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK; |
37 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
38 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
39 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
40 | A9MPPrivState a9mpcore; | ||
41 | Exynos4210GicState ext_gic; | ||
42 | + SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS]; | ||
43 | }; | ||
44 | |||
45 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
46 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
47 | index XXXXXXX..XXXXXXX 100644 | ||
48 | --- a/hw/arm/exynos4210.c | ||
49 | +++ b/hw/arm/exynos4210.c | ||
50 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
51 | uint32_t grp, bit, irq_id, n; | ||
52 | Exynos4210Irq *is = &s->irqs; | ||
53 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
54 | + int splitcount = 0; | ||
55 | + DeviceState *splitter; | ||
56 | |||
57 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
58 | irq_id = 0; | ||
59 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
60 | /* MCT_G1 is passed to External and GIC */ | ||
61 | irq_id = EXT_GIC_ID_MCT_G1; | ||
62 | } | ||
63 | + | ||
64 | + assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
65 | + splitter = DEVICE(&s->splitter[splitcount]); | ||
66 | + qdev_prop_set_uint16(splitter, "num-lines", 2); | ||
67 | + qdev_realize(splitter, NULL, &error_abort); | ||
68 | + splitcount++; | ||
69 | + s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
70 | + qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
71 | if (irq_id) { | ||
72 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
73 | - qdev_get_gpio_in(extgicdev, | ||
74 | - irq_id - 32)); | ||
75 | + qdev_connect_gpio_out(splitter, 1, | ||
76 | + qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
77 | } else { | ||
78 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
79 | - is->ext_combiner_irq[n]); | ||
80 | + qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
81 | } | ||
82 | } | ||
83 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
84 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
85 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
86 | |||
87 | if (irq_id) { | ||
88 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
89 | - qdev_get_gpio_in(extgicdev, | ||
90 | - irq_id - 32)); | ||
91 | + assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
92 | + splitter = DEVICE(&s->splitter[splitcount]); | ||
93 | + qdev_prop_set_uint16(splitter, "num-lines", 2); | ||
94 | + qdev_realize(splitter, NULL, &error_abort); | ||
95 | + splitcount++; | ||
96 | + s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
97 | + qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
98 | + qdev_connect_gpio_out(splitter, 1, | ||
99 | + qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
100 | } | ||
101 | } | ||
102 | + /* | ||
103 | + * We check this here to avoid a more obscure assert later when | ||
104 | + * qdev_assert_realized_properly() checks that we realized every | ||
105 | + * child object we initialized. | ||
106 | + */ | ||
107 | + assert(splitcount == EXYNOS4210_NUM_SPLITTERS); | ||
108 | } | ||
109 | |||
110 | /* | ||
111 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
112 | object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); | ||
113 | } | ||
114 | |||
115 | + for (i = 0; i < ARRAY_SIZE(s->splitter); i++) { | ||
116 | + g_autofree char *name = g_strdup_printf("irq-splitter%d", i); | ||
117 | + object_initialize_child(obj, name, &s->splitter[i], TYPE_SPLIT_IRQ); | ||
118 | + } | 36 | + } |
119 | + | 37 | + |
120 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | 38 | + /* Clear RES0 bits */ |
121 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | 39 | + value &= valid_mask; |
122 | } | 40 | + |
41 | raw_write(env, ri, value); | ||
42 | |||
43 | if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) { | ||
123 | -- | 44 | -- |
124 | 2.25.1 | 45 | 2.34.1 | diff view generated by jsdifflib |
1 | The function exynos4210_init_board_irqs() currently lives in | 1 | The functionality defined by ID_AA64MMFR0_EL1.ECV == 1 is: |
---|---|---|---|
2 | exynos4210_gic.c, but it isn't really part of the exynos4210.gic | 2 | * four new trap bits for various counter and timer registers |
3 | device -- it is a function that implements (some of) the wiring up of | 3 | * the CNTHCTL_EL2.EVNTIS and CNTKCTL_EL1.EVNTIS bits which control |
4 | interrupts between the SoC's GIC and combiner components. This means | 4 | scaling of the event stream. This is a no-op for us, because we don't |
5 | it fits better in exynos4210.c, which is the SoC-level code. Move it | 5 | implement the event stream (our WFE is a NOP): all we need to do is |
6 | there. Similarly, exynos4210_git_irq() is used almost only in the | 6 | allow CNTHCTL_EL2.ENVTIS to be read and written. |
7 | SoC-level code, so move it too. | 7 | * extensions to PMSCR_EL1.PCT, PMSCR_EL2.PCT, TRFCR_EL1.TS and |
8 | TRFCR_EL2.TS: these are all no-ops for us, because we don't implement | ||
9 | FEAT_SPE or FEAT_TRF. | ||
10 | * new registers CNTPCTSS_EL0 and NCTVCTSS_EL0 which are | ||
11 | "self-sychronizing" views of the CNTPCT_EL0 and CNTVCT_EL0, meaning | ||
12 | that no barriers are needed around their accesses. For us these | ||
13 | are just the same as the normal views, because all our sysregs are | ||
14 | inherently self-sychronizing. | ||
15 | |||
16 | In this commit we implement the trap handling and permit the new | ||
17 | CNTHCTL_EL2 bits to be written. | ||
8 | 18 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 19 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 20 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20220404154658.565020-8-peter.maydell@linaro.org | 21 | Message-id: 20240301183219.2424889-6-peter.maydell@linaro.org |
12 | --- | 22 | --- |
13 | include/hw/arm/exynos4210.h | 4 - | 23 | target/arm/cpu-features.h | 5 ++++ |
14 | hw/arm/exynos4210.c | 202 +++++++++++++++++++++++++++++++++++ | 24 | target/arm/helper.c | 51 +++++++++++++++++++++++++++++++++++---- |
15 | hw/intc/exynos4210_gic.c | 204 ------------------------------------ | 25 | 2 files changed, 51 insertions(+), 5 deletions(-) |
16 | 3 files changed, 202 insertions(+), 208 deletions(-) | ||
17 | 26 | ||
18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 27 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
19 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/exynos4210.h | 29 | --- a/target/arm/cpu-features.h |
21 | +++ b/include/hw/arm/exynos4210.h | 30 | +++ b/target/arm/cpu-features.h |
22 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) | 31 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_fgt(const ARMISARegisters *id) |
23 | void exynos4210_write_secondary(ARMCPU *cpu, | 32 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, FGT) != 0; |
24 | const struct arm_boot_info *info); | 33 | } |
25 | 34 | ||
26 | -/* Initialize board IRQs. | 35 | +static inline bool isar_feature_aa64_ecv_traps(const ARMISARegisters *id) |
27 | - * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ | 36 | +{ |
28 | -void exynos4210_init_board_irqs(Exynos4210State *s); | 37 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 0; |
29 | - | 38 | +} |
30 | /* Get IRQ number from exynos4210 IRQ subsystem stub. | 39 | + |
31 | * To identify IRQ source use internal combiner group and bit number | 40 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
32 | * grp - group number | 41 | { |
33 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 42 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; |
43 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
34 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
35 | --- a/hw/arm/exynos4210.c | 45 | --- a/target/arm/helper.c |
36 | +++ b/hw/arm/exynos4210.c | 46 | +++ b/target/arm/helper.c |
37 | @@ -XXX,XX +XXX,XX @@ | 47 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx, |
38 | #define EXYNOS4210_PL330_BASE1_ADDR 0x12690000 | 48 | : !extract32(env->cp15.cnthctl_el2, 0, 1))) { |
39 | #define EXYNOS4210_PL330_BASE2_ADDR 0x12850000 | 49 | return CP_ACCESS_TRAP_EL2; |
40 | 50 | } | |
41 | +enum ExtGicId { | 51 | + if (has_el2 && timeridx == GTIMER_VIRT) { |
42 | + EXT_GIC_ID_MDMA_LCD0 = 66, | 52 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1TVCT)) { |
43 | + EXT_GIC_ID_PDMA0, | 53 | + return CP_ACCESS_TRAP_EL2; |
44 | + EXT_GIC_ID_PDMA1, | 54 | + } |
45 | + EXT_GIC_ID_TIMER0, | 55 | + } |
46 | + EXT_GIC_ID_TIMER1, | 56 | break; |
47 | + EXT_GIC_ID_TIMER2, | 57 | } |
48 | + EXT_GIC_ID_TIMER3, | 58 | return CP_ACCESS_OK; |
49 | + EXT_GIC_ID_TIMER4, | 59 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx, |
50 | + EXT_GIC_ID_MCT_L0, | 60 | } |
51 | + EXT_GIC_ID_WDT, | 61 | } |
52 | + EXT_GIC_ID_RTC_ALARM, | 62 | } |
53 | + EXT_GIC_ID_RTC_TIC, | 63 | + if (has_el2 && timeridx == GTIMER_VIRT) { |
54 | + EXT_GIC_ID_GPIO_XB, | 64 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1TVT)) { |
55 | + EXT_GIC_ID_GPIO_XA, | 65 | + return CP_ACCESS_TRAP_EL2; |
56 | + EXT_GIC_ID_MCT_L1, | 66 | + } |
57 | + EXT_GIC_ID_IEM_APC, | 67 | + } |
58 | + EXT_GIC_ID_IEM_IEC, | 68 | break; |
59 | + EXT_GIC_ID_NFC, | 69 | } |
60 | + EXT_GIC_ID_UART0, | 70 | return CP_ACCESS_OK; |
61 | + EXT_GIC_ID_UART1, | 71 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, |
62 | + EXT_GIC_ID_UART2, | 72 | if (cpu_isar_feature(aa64_rme, cpu)) { |
63 | + EXT_GIC_ID_UART3, | 73 | valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK; |
64 | + EXT_GIC_ID_UART4, | 74 | } |
65 | + EXT_GIC_ID_MCT_G0, | 75 | + if (cpu_isar_feature(aa64_ecv_traps, cpu)) { |
66 | + EXT_GIC_ID_I2C0, | 76 | + valid_mask |= |
67 | + EXT_GIC_ID_I2C1, | 77 | + R_CNTHCTL_EL1TVT_MASK | |
68 | + EXT_GIC_ID_I2C2, | 78 | + R_CNTHCTL_EL1TVCT_MASK | |
69 | + EXT_GIC_ID_I2C3, | 79 | + R_CNTHCTL_EL1NVPCT_MASK | |
70 | + EXT_GIC_ID_I2C4, | 80 | + R_CNTHCTL_EL1NVVCT_MASK | |
71 | + EXT_GIC_ID_I2C5, | 81 | + R_CNTHCTL_EVNTIS_MASK; |
72 | + EXT_GIC_ID_I2C6, | 82 | + } |
73 | + EXT_GIC_ID_I2C7, | 83 | |
74 | + EXT_GIC_ID_SPI0, | 84 | /* Clear RES0 bits */ |
75 | + EXT_GIC_ID_SPI1, | 85 | value &= valid_mask; |
76 | + EXT_GIC_ID_SPI2, | 86 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, |
77 | + EXT_GIC_ID_MCT_G1, | 87 | { |
78 | + EXT_GIC_ID_USB_HOST, | 88 | if (arm_current_el(env) == 1) { |
79 | + EXT_GIC_ID_USB_DEVICE, | 89 | /* This must be a FEAT_NV access */ |
80 | + EXT_GIC_ID_MODEMIF, | 90 | - /* TODO: FEAT_ECV will need to check CNTHCTL_EL2 here */ |
81 | + EXT_GIC_ID_HSMMC0, | 91 | return CP_ACCESS_OK; |
82 | + EXT_GIC_ID_HSMMC1, | 92 | } |
83 | + EXT_GIC_ID_HSMMC2, | 93 | if (!(arm_hcr_el2_eff(env) & HCR_E2H)) { |
84 | + EXT_GIC_ID_HSMMC3, | 94 | @@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri, |
85 | + EXT_GIC_ID_SDMMC, | 95 | return CP_ACCESS_OK; |
86 | + EXT_GIC_ID_MIPI_CSI_4LANE, | 96 | } |
87 | + EXT_GIC_ID_MIPI_DSI_4LANE, | 97 | |
88 | + EXT_GIC_ID_MIPI_CSI_2LANE, | 98 | +static CPAccessResult access_el1nvpct(CPUARMState *env, const ARMCPRegInfo *ri, |
89 | + EXT_GIC_ID_MIPI_DSI_2LANE, | 99 | + bool isread) |
90 | + EXT_GIC_ID_ONENAND_AUDI, | ||
91 | + EXT_GIC_ID_ROTATOR, | ||
92 | + EXT_GIC_ID_FIMC0, | ||
93 | + EXT_GIC_ID_FIMC1, | ||
94 | + EXT_GIC_ID_FIMC2, | ||
95 | + EXT_GIC_ID_FIMC3, | ||
96 | + EXT_GIC_ID_JPEG, | ||
97 | + EXT_GIC_ID_2D, | ||
98 | + EXT_GIC_ID_PCIe, | ||
99 | + EXT_GIC_ID_MIXER, | ||
100 | + EXT_GIC_ID_HDMI, | ||
101 | + EXT_GIC_ID_HDMI_I2C, | ||
102 | + EXT_GIC_ID_MFC, | ||
103 | + EXT_GIC_ID_TVENC, | ||
104 | +}; | ||
105 | + | ||
106 | +enum ExtInt { | ||
107 | + EXT_GIC_ID_EXTINT0 = 48, | ||
108 | + EXT_GIC_ID_EXTINT1, | ||
109 | + EXT_GIC_ID_EXTINT2, | ||
110 | + EXT_GIC_ID_EXTINT3, | ||
111 | + EXT_GIC_ID_EXTINT4, | ||
112 | + EXT_GIC_ID_EXTINT5, | ||
113 | + EXT_GIC_ID_EXTINT6, | ||
114 | + EXT_GIC_ID_EXTINT7, | ||
115 | + EXT_GIC_ID_EXTINT8, | ||
116 | + EXT_GIC_ID_EXTINT9, | ||
117 | + EXT_GIC_ID_EXTINT10, | ||
118 | + EXT_GIC_ID_EXTINT11, | ||
119 | + EXT_GIC_ID_EXTINT12, | ||
120 | + EXT_GIC_ID_EXTINT13, | ||
121 | + EXT_GIC_ID_EXTINT14, | ||
122 | + EXT_GIC_ID_EXTINT15 | ||
123 | +}; | ||
124 | + | ||
125 | +/* | ||
126 | + * External GIC sources which are not from External Interrupt Combiner or | ||
127 | + * External Interrupts are starting from EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ, | ||
128 | + * which is INTG16 in Internal Interrupt Combiner. | ||
129 | + */ | ||
130 | + | ||
131 | +static const uint32_t | ||
132 | +combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
133 | + /* int combiner groups 16-19 */ | ||
134 | + { }, { }, { }, { }, | ||
135 | + /* int combiner group 20 */ | ||
136 | + { 0, EXT_GIC_ID_MDMA_LCD0 }, | ||
137 | + /* int combiner group 21 */ | ||
138 | + { EXT_GIC_ID_PDMA0, EXT_GIC_ID_PDMA1 }, | ||
139 | + /* int combiner group 22 */ | ||
140 | + { EXT_GIC_ID_TIMER0, EXT_GIC_ID_TIMER1, EXT_GIC_ID_TIMER2, | ||
141 | + EXT_GIC_ID_TIMER3, EXT_GIC_ID_TIMER4 }, | ||
142 | + /* int combiner group 23 */ | ||
143 | + { EXT_GIC_ID_RTC_ALARM, EXT_GIC_ID_RTC_TIC }, | ||
144 | + /* int combiner group 24 */ | ||
145 | + { EXT_GIC_ID_GPIO_XB, EXT_GIC_ID_GPIO_XA }, | ||
146 | + /* int combiner group 25 */ | ||
147 | + { EXT_GIC_ID_IEM_APC, EXT_GIC_ID_IEM_IEC }, | ||
148 | + /* int combiner group 26 */ | ||
149 | + { EXT_GIC_ID_UART0, EXT_GIC_ID_UART1, EXT_GIC_ID_UART2, EXT_GIC_ID_UART3, | ||
150 | + EXT_GIC_ID_UART4 }, | ||
151 | + /* int combiner group 27 */ | ||
152 | + { EXT_GIC_ID_I2C0, EXT_GIC_ID_I2C1, EXT_GIC_ID_I2C2, EXT_GIC_ID_I2C3, | ||
153 | + EXT_GIC_ID_I2C4, EXT_GIC_ID_I2C5, EXT_GIC_ID_I2C6, | ||
154 | + EXT_GIC_ID_I2C7 }, | ||
155 | + /* int combiner group 28 */ | ||
156 | + { EXT_GIC_ID_SPI0, EXT_GIC_ID_SPI1, EXT_GIC_ID_SPI2 , EXT_GIC_ID_USB_HOST}, | ||
157 | + /* int combiner group 29 */ | ||
158 | + { EXT_GIC_ID_HSMMC0, EXT_GIC_ID_HSMMC1, EXT_GIC_ID_HSMMC2, | ||
159 | + EXT_GIC_ID_HSMMC3, EXT_GIC_ID_SDMMC }, | ||
160 | + /* int combiner group 30 */ | ||
161 | + { EXT_GIC_ID_MIPI_CSI_4LANE, EXT_GIC_ID_MIPI_CSI_2LANE }, | ||
162 | + /* int combiner group 31 */ | ||
163 | + { EXT_GIC_ID_MIPI_DSI_4LANE, EXT_GIC_ID_MIPI_DSI_2LANE }, | ||
164 | + /* int combiner group 32 */ | ||
165 | + { EXT_GIC_ID_FIMC0, EXT_GIC_ID_FIMC1 }, | ||
166 | + /* int combiner group 33 */ | ||
167 | + { EXT_GIC_ID_FIMC2, EXT_GIC_ID_FIMC3 }, | ||
168 | + /* int combiner group 34 */ | ||
169 | + { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | ||
170 | + /* int combiner group 35 */ | ||
171 | + { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
172 | + /* int combiner group 36 */ | ||
173 | + { EXT_GIC_ID_MIXER }, | ||
174 | + /* int combiner group 37 */ | ||
175 | + { EXT_GIC_ID_EXTINT4, EXT_GIC_ID_EXTINT5, EXT_GIC_ID_EXTINT6, | ||
176 | + EXT_GIC_ID_EXTINT7 }, | ||
177 | + /* groups 38-50 */ | ||
178 | + { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | ||
179 | + /* int combiner group 51 */ | ||
180 | + { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
181 | + /* group 52 */ | ||
182 | + { }, | ||
183 | + /* int combiner group 53 */ | ||
184 | + { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
185 | + /* groups 54-63 */ | ||
186 | + { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
187 | +}; | ||
188 | + | ||
189 | +/* | ||
190 | + * Initialize board IRQs. | ||
191 | + * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
192 | + */ | ||
193 | +static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
194 | +{ | 100 | +{ |
195 | + uint32_t grp, bit, irq_id, n; | 101 | + if (arm_current_el(env) == 1) { |
196 | + Exynos4210Irq *is = &s->irqs; | 102 | + /* This must be a FEAT_NV access with NVx == 101 */ |
197 | + | 103 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1NVPCT)) { |
198 | + for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | 104 | + return CP_ACCESS_TRAP_EL2; |
199 | + irq_id = 0; | ||
200 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | ||
201 | + n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | ||
202 | + /* MCT_G0 is passed to External GIC */ | ||
203 | + irq_id = EXT_GIC_ID_MCT_G0; | ||
204 | + } | ||
205 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | ||
206 | + n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | ||
207 | + /* MCT_G1 is passed to External and GIC */ | ||
208 | + irq_id = EXT_GIC_ID_MCT_G1; | ||
209 | + } | ||
210 | + if (irq_id) { | ||
211 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
212 | + is->ext_gic_irq[irq_id - 32]); | ||
213 | + } else { | ||
214 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
215 | + is->ext_combiner_irq[n]); | ||
216 | + } | 105 | + } |
217 | + } | 106 | + } |
218 | + for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | 107 | + return e2h_access(env, ri, isread); |
219 | + /* these IDs are passed to Internal Combiner and External GIC */ | 108 | +} |
220 | + grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n); | ||
221 | + bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
222 | + irq_id = combiner_grp_to_gic_id[grp - | ||
223 | + EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
224 | + | 109 | + |
225 | + if (irq_id) { | 110 | +static CPAccessResult access_el1nvvct(CPUARMState *env, const ARMCPRegInfo *ri, |
226 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | 111 | + bool isread) |
227 | + is->ext_gic_irq[irq_id - 32]); | 112 | +{ |
113 | + if (arm_current_el(env) == 1) { | ||
114 | + /* This must be a FEAT_NV access with NVx == 101 */ | ||
115 | + if (FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, EL1NVVCT)) { | ||
116 | + return CP_ACCESS_TRAP_EL2; | ||
228 | + } | 117 | + } |
229 | + } | 118 | + } |
119 | + return e2h_access(env, ri, isread); | ||
230 | +} | 120 | +} |
231 | + | 121 | + |
232 | +/* | 122 | /* Test if system register redirection is to occur in the current state. */ |
233 | + * Get IRQ number from exynos4210 IRQ subsystem stub. | 123 | static bool redirect_for_e2h(CPUARMState *env) |
234 | + * To identify IRQ source use internal combiner group and bit number | 124 | { |
235 | + * grp - group number | 125 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { |
236 | + * bit - bit number inside group | 126 | { .name = "CNTP_CTL_EL02", .state = ARM_CP_STATE_AA64, |
237 | + */ | 127 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 2, .opc2 = 1, |
238 | +uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | 128 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
239 | +{ | 129 | - .access = PL2_RW, .accessfn = e2h_access, |
240 | + return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | 130 | + .access = PL2_RW, .accessfn = access_el1nvpct, |
241 | +} | 131 | .nv2_redirect_offset = 0x180 | NV2_REDIR_NO_NV1, |
242 | + | 132 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_PHYS].ctl), |
243 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | 133 | .writefn = gt_phys_ctl_write, .raw_writefn = raw_write }, |
244 | 0x09, 0x00, 0x00, 0x00 }; | 134 | { .name = "CNTV_CTL_EL02", .state = ARM_CP_STATE_AA64, |
245 | 135 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 3, .opc2 = 1, | |
246 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | 136 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
247 | index XXXXXXX..XXXXXXX 100644 | 137 | - .access = PL2_RW, .accessfn = e2h_access, |
248 | --- a/hw/intc/exynos4210_gic.c | 138 | + .access = PL2_RW, .accessfn = access_el1nvvct, |
249 | +++ b/hw/intc/exynos4210_gic.c | 139 | .nv2_redirect_offset = 0x170 | NV2_REDIR_NO_NV1, |
250 | @@ -XXX,XX +XXX,XX @@ | 140 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].ctl), |
251 | #include "hw/arm/exynos4210.h" | 141 | .writefn = gt_virt_ctl_write, .raw_writefn = raw_write }, |
252 | #include "qom/object.h" | 142 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vhe_reginfo[] = { |
253 | 143 | .type = ARM_CP_IO | ARM_CP_ALIAS, | |
254 | -enum ExtGicId { | 144 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_PHYS].cval), |
255 | - EXT_GIC_ID_MDMA_LCD0 = 66, | 145 | .nv2_redirect_offset = 0x178 | NV2_REDIR_NO_NV1, |
256 | - EXT_GIC_ID_PDMA0, | 146 | - .access = PL2_RW, .accessfn = e2h_access, |
257 | - EXT_GIC_ID_PDMA1, | 147 | + .access = PL2_RW, .accessfn = access_el1nvpct, |
258 | - EXT_GIC_ID_TIMER0, | 148 | .writefn = gt_phys_cval_write, .raw_writefn = raw_write }, |
259 | - EXT_GIC_ID_TIMER1, | 149 | { .name = "CNTV_CVAL_EL02", .state = ARM_CP_STATE_AA64, |
260 | - EXT_GIC_ID_TIMER2, | 150 | .opc0 = 3, .opc1 = 5, .crn = 14, .crm = 3, .opc2 = 2, |
261 | - EXT_GIC_ID_TIMER3, | 151 | .type = ARM_CP_IO | ARM_CP_ALIAS, |
262 | - EXT_GIC_ID_TIMER4, | 152 | .nv2_redirect_offset = 0x168 | NV2_REDIR_NO_NV1, |
263 | - EXT_GIC_ID_MCT_L0, | 153 | .fieldoffset = offsetof(CPUARMState, cp15.c14_timer[GTIMER_VIRT].cval), |
264 | - EXT_GIC_ID_WDT, | 154 | - .access = PL2_RW, .accessfn = e2h_access, |
265 | - EXT_GIC_ID_RTC_ALARM, | 155 | + .access = PL2_RW, .accessfn = access_el1nvvct, |
266 | - EXT_GIC_ID_RTC_TIC, | 156 | .writefn = gt_virt_cval_write, .raw_writefn = raw_write }, |
267 | - EXT_GIC_ID_GPIO_XB, | 157 | #endif |
268 | - EXT_GIC_ID_GPIO_XA, | 158 | }; |
269 | - EXT_GIC_ID_MCT_L1, | ||
270 | - EXT_GIC_ID_IEM_APC, | ||
271 | - EXT_GIC_ID_IEM_IEC, | ||
272 | - EXT_GIC_ID_NFC, | ||
273 | - EXT_GIC_ID_UART0, | ||
274 | - EXT_GIC_ID_UART1, | ||
275 | - EXT_GIC_ID_UART2, | ||
276 | - EXT_GIC_ID_UART3, | ||
277 | - EXT_GIC_ID_UART4, | ||
278 | - EXT_GIC_ID_MCT_G0, | ||
279 | - EXT_GIC_ID_I2C0, | ||
280 | - EXT_GIC_ID_I2C1, | ||
281 | - EXT_GIC_ID_I2C2, | ||
282 | - EXT_GIC_ID_I2C3, | ||
283 | - EXT_GIC_ID_I2C4, | ||
284 | - EXT_GIC_ID_I2C5, | ||
285 | - EXT_GIC_ID_I2C6, | ||
286 | - EXT_GIC_ID_I2C7, | ||
287 | - EXT_GIC_ID_SPI0, | ||
288 | - EXT_GIC_ID_SPI1, | ||
289 | - EXT_GIC_ID_SPI2, | ||
290 | - EXT_GIC_ID_MCT_G1, | ||
291 | - EXT_GIC_ID_USB_HOST, | ||
292 | - EXT_GIC_ID_USB_DEVICE, | ||
293 | - EXT_GIC_ID_MODEMIF, | ||
294 | - EXT_GIC_ID_HSMMC0, | ||
295 | - EXT_GIC_ID_HSMMC1, | ||
296 | - EXT_GIC_ID_HSMMC2, | ||
297 | - EXT_GIC_ID_HSMMC3, | ||
298 | - EXT_GIC_ID_SDMMC, | ||
299 | - EXT_GIC_ID_MIPI_CSI_4LANE, | ||
300 | - EXT_GIC_ID_MIPI_DSI_4LANE, | ||
301 | - EXT_GIC_ID_MIPI_CSI_2LANE, | ||
302 | - EXT_GIC_ID_MIPI_DSI_2LANE, | ||
303 | - EXT_GIC_ID_ONENAND_AUDI, | ||
304 | - EXT_GIC_ID_ROTATOR, | ||
305 | - EXT_GIC_ID_FIMC0, | ||
306 | - EXT_GIC_ID_FIMC1, | ||
307 | - EXT_GIC_ID_FIMC2, | ||
308 | - EXT_GIC_ID_FIMC3, | ||
309 | - EXT_GIC_ID_JPEG, | ||
310 | - EXT_GIC_ID_2D, | ||
311 | - EXT_GIC_ID_PCIe, | ||
312 | - EXT_GIC_ID_MIXER, | ||
313 | - EXT_GIC_ID_HDMI, | ||
314 | - EXT_GIC_ID_HDMI_I2C, | ||
315 | - EXT_GIC_ID_MFC, | ||
316 | - EXT_GIC_ID_TVENC, | ||
317 | -}; | ||
318 | - | ||
319 | -enum ExtInt { | ||
320 | - EXT_GIC_ID_EXTINT0 = 48, | ||
321 | - EXT_GIC_ID_EXTINT1, | ||
322 | - EXT_GIC_ID_EXTINT2, | ||
323 | - EXT_GIC_ID_EXTINT3, | ||
324 | - EXT_GIC_ID_EXTINT4, | ||
325 | - EXT_GIC_ID_EXTINT5, | ||
326 | - EXT_GIC_ID_EXTINT6, | ||
327 | - EXT_GIC_ID_EXTINT7, | ||
328 | - EXT_GIC_ID_EXTINT8, | ||
329 | - EXT_GIC_ID_EXTINT9, | ||
330 | - EXT_GIC_ID_EXTINT10, | ||
331 | - EXT_GIC_ID_EXTINT11, | ||
332 | - EXT_GIC_ID_EXTINT12, | ||
333 | - EXT_GIC_ID_EXTINT13, | ||
334 | - EXT_GIC_ID_EXTINT14, | ||
335 | - EXT_GIC_ID_EXTINT15 | ||
336 | -}; | ||
337 | - | ||
338 | -/* | ||
339 | - * External GIC sources which are not from External Interrupt Combiner or | ||
340 | - * External Interrupts are starting from EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ, | ||
341 | - * which is INTG16 in Internal Interrupt Combiner. | ||
342 | - */ | ||
343 | - | ||
344 | -static const uint32_t | ||
345 | -combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
346 | - /* int combiner groups 16-19 */ | ||
347 | - { }, { }, { }, { }, | ||
348 | - /* int combiner group 20 */ | ||
349 | - { 0, EXT_GIC_ID_MDMA_LCD0 }, | ||
350 | - /* int combiner group 21 */ | ||
351 | - { EXT_GIC_ID_PDMA0, EXT_GIC_ID_PDMA1 }, | ||
352 | - /* int combiner group 22 */ | ||
353 | - { EXT_GIC_ID_TIMER0, EXT_GIC_ID_TIMER1, EXT_GIC_ID_TIMER2, | ||
354 | - EXT_GIC_ID_TIMER3, EXT_GIC_ID_TIMER4 }, | ||
355 | - /* int combiner group 23 */ | ||
356 | - { EXT_GIC_ID_RTC_ALARM, EXT_GIC_ID_RTC_TIC }, | ||
357 | - /* int combiner group 24 */ | ||
358 | - { EXT_GIC_ID_GPIO_XB, EXT_GIC_ID_GPIO_XA }, | ||
359 | - /* int combiner group 25 */ | ||
360 | - { EXT_GIC_ID_IEM_APC, EXT_GIC_ID_IEM_IEC }, | ||
361 | - /* int combiner group 26 */ | ||
362 | - { EXT_GIC_ID_UART0, EXT_GIC_ID_UART1, EXT_GIC_ID_UART2, EXT_GIC_ID_UART3, | ||
363 | - EXT_GIC_ID_UART4 }, | ||
364 | - /* int combiner group 27 */ | ||
365 | - { EXT_GIC_ID_I2C0, EXT_GIC_ID_I2C1, EXT_GIC_ID_I2C2, EXT_GIC_ID_I2C3, | ||
366 | - EXT_GIC_ID_I2C4, EXT_GIC_ID_I2C5, EXT_GIC_ID_I2C6, | ||
367 | - EXT_GIC_ID_I2C7 }, | ||
368 | - /* int combiner group 28 */ | ||
369 | - { EXT_GIC_ID_SPI0, EXT_GIC_ID_SPI1, EXT_GIC_ID_SPI2 , EXT_GIC_ID_USB_HOST}, | ||
370 | - /* int combiner group 29 */ | ||
371 | - { EXT_GIC_ID_HSMMC0, EXT_GIC_ID_HSMMC1, EXT_GIC_ID_HSMMC2, | ||
372 | - EXT_GIC_ID_HSMMC3, EXT_GIC_ID_SDMMC }, | ||
373 | - /* int combiner group 30 */ | ||
374 | - { EXT_GIC_ID_MIPI_CSI_4LANE, EXT_GIC_ID_MIPI_CSI_2LANE }, | ||
375 | - /* int combiner group 31 */ | ||
376 | - { EXT_GIC_ID_MIPI_DSI_4LANE, EXT_GIC_ID_MIPI_DSI_2LANE }, | ||
377 | - /* int combiner group 32 */ | ||
378 | - { EXT_GIC_ID_FIMC0, EXT_GIC_ID_FIMC1 }, | ||
379 | - /* int combiner group 33 */ | ||
380 | - { EXT_GIC_ID_FIMC2, EXT_GIC_ID_FIMC3 }, | ||
381 | - /* int combiner group 34 */ | ||
382 | - { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | ||
383 | - /* int combiner group 35 */ | ||
384 | - { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
385 | - /* int combiner group 36 */ | ||
386 | - { EXT_GIC_ID_MIXER }, | ||
387 | - /* int combiner group 37 */ | ||
388 | - { EXT_GIC_ID_EXTINT4, EXT_GIC_ID_EXTINT5, EXT_GIC_ID_EXTINT6, | ||
389 | - EXT_GIC_ID_EXTINT7 }, | ||
390 | - /* groups 38-50 */ | ||
391 | - { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | ||
392 | - /* int combiner group 51 */ | ||
393 | - { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
394 | - /* group 52 */ | ||
395 | - { }, | ||
396 | - /* int combiner group 53 */ | ||
397 | - { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
398 | - /* groups 54-63 */ | ||
399 | - { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
400 | -}; | ||
401 | - | ||
402 | #define EXYNOS4210_GIC_NIRQ 160 | ||
403 | |||
404 | #define EXYNOS4210_EXT_GIC_CPU_REGION_SIZE 0x10000 | ||
405 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
406 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
407 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
408 | |||
409 | -/* | ||
410 | - * Initialize board IRQs. | ||
411 | - * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
412 | - */ | ||
413 | -void exynos4210_init_board_irqs(Exynos4210State *s) | ||
414 | -{ | ||
415 | - uint32_t grp, bit, irq_id, n; | ||
416 | - Exynos4210Irq *is = &s->irqs; | ||
417 | - | ||
418 | - for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
419 | - irq_id = 0; | ||
420 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | ||
421 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | ||
422 | - /* MCT_G0 is passed to External GIC */ | ||
423 | - irq_id = EXT_GIC_ID_MCT_G0; | ||
424 | - } | ||
425 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | ||
426 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | ||
427 | - /* MCT_G1 is passed to External and GIC */ | ||
428 | - irq_id = EXT_GIC_ID_MCT_G1; | ||
429 | - } | ||
430 | - if (irq_id) { | ||
431 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
432 | - is->ext_gic_irq[irq_id - 32]); | ||
433 | - } else { | ||
434 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
435 | - is->ext_combiner_irq[n]); | ||
436 | - } | ||
437 | - } | ||
438 | - for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
439 | - /* these IDs are passed to Internal Combiner and External GIC */ | ||
440 | - grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n); | ||
441 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
442 | - irq_id = combiner_grp_to_gic_id[grp - | ||
443 | - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
444 | - | ||
445 | - if (irq_id) { | ||
446 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
447 | - is->ext_gic_irq[irq_id - 32]); | ||
448 | - } | ||
449 | - } | ||
450 | -} | ||
451 | - | ||
452 | -/* | ||
453 | - * Get IRQ number from exynos4210 IRQ subsystem stub. | ||
454 | - * To identify IRQ source use internal combiner group and bit number | ||
455 | - * grp - group number | ||
456 | - * bit - bit number inside group | ||
457 | - */ | ||
458 | -uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
459 | -{ | ||
460 | - return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
461 | -} | ||
462 | - | ||
463 | -/********* GIC part *********/ | ||
464 | - | ||
465 | #define TYPE_EXYNOS4210_GIC "exynos4210.gic" | ||
466 | OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | ||
467 | |||
468 | -- | 159 | -- |
469 | 2.25.1 | 160 | 2.34.1 | diff view generated by jsdifflib |
1 | Switch the creation of the external GIC to the new-style "embedded in | 1 | For FEAT_ECV, new registers CNTPCTSS_EL0 and CNTVCTSS_EL0 are |
---|---|---|---|
2 | state struct" approach, so we can easily refer to the object | 2 | defined, which are "self-synchronized" views of the physical and |
3 | elsewhere during realize. | 3 | virtual counts as seen in the CNTPCT_EL0 and CNTVCT_EL0 registers |
4 | (meaning that no barriers are needed around accesses to them to | ||
5 | ensure that reads of them do not occur speculatively and out-of-order | ||
6 | with other instructions). | ||
7 | |||
8 | For QEMU, all our system registers are self-synchronized, so we can | ||
9 | simply copy the existing implementation of CNTPCT_EL0 and CNTVCT_EL0 | ||
10 | to the new register encodings. | ||
11 | |||
12 | This means we now implement all the functionality required for | ||
13 | ID_AA64MMFR0_EL1.ECV == 0b0001. | ||
4 | 14 | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
7 | Message-id: 20220404154658.565020-9-peter.maydell@linaro.org | 17 | Message-id: 20240301183219.2424889-7-peter.maydell@linaro.org |
8 | --- | 18 | --- |
9 | include/hw/arm/exynos4210.h | 2 ++ | 19 | target/arm/helper.c | 43 +++++++++++++++++++++++++++++++++++++++++++ |
10 | include/hw/intc/exynos4210_gic.h | 43 ++++++++++++++++++++++++++++++++ | 20 | 1 file changed, 43 insertions(+) |
11 | hw/arm/exynos4210.c | 10 ++++---- | ||
12 | hw/intc/exynos4210_gic.c | 17 ++----------- | ||
13 | MAINTAINERS | 2 +- | ||
14 | 5 files changed, 53 insertions(+), 21 deletions(-) | ||
15 | create mode 100644 include/hw/intc/exynos4210_gic.h | ||
16 | 21 | ||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 22 | diff --git a/target/arm/helper.c b/target/arm/helper.c |
18 | index XXXXXXX..XXXXXXX 100644 | 23 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/exynos4210.h | 24 | --- a/target/arm/helper.c |
20 | +++ b/include/hw/arm/exynos4210.h | 25 | +++ b/target/arm/helper.c |
21 | @@ -XXX,XX +XXX,XX @@ | 26 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
22 | #include "hw/or-irq.h" | 27 | }, |
23 | #include "hw/sysbus.h" | ||
24 | #include "hw/cpu/a9mpcore.h" | ||
25 | +#include "hw/intc/exynos4210_gic.h" | ||
26 | #include "target/arm/cpu-qom.h" | ||
27 | #include "qom/object.h" | ||
28 | |||
29 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
30 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | ||
31 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
32 | A9MPPrivState a9mpcore; | ||
33 | + Exynos4210GicState ext_gic; | ||
34 | }; | 28 | }; |
35 | 29 | ||
36 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
37 | diff --git a/include/hw/intc/exynos4210_gic.h b/include/hw/intc/exynos4210_gic.h | ||
38 | new file mode 100644 | ||
39 | index XXXXXXX..XXXXXXX | ||
40 | --- /dev/null | ||
41 | +++ b/include/hw/intc/exynos4210_gic.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | +/* | 30 | +/* |
44 | + * Samsung exynos4210 GIC implementation. Based on hw/arm_gic.c | 31 | + * FEAT_ECV adds extra views of CNTVCT_EL0 and CNTPCT_EL0 which |
45 | + * | 32 | + * are "self-synchronizing". For QEMU all sysregs are self-synchronizing, |
46 | + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. | 33 | + * so our implementations here are identical to the normal registers. |
47 | + * All rights reserved. | ||
48 | + * | ||
49 | + * Evgeny Voevodin <e.voevodin@samsung.com> | ||
50 | + * | ||
51 | + * This program is free software; you can redistribute it and/or modify it | ||
52 | + * under the terms of the GNU General Public License as published by the | ||
53 | + * Free Software Foundation; either version 2 of the License, or (at your | ||
54 | + * option) any later version. | ||
55 | + * | ||
56 | + * This program is distributed in the hope that it will be useful, | ||
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
59 | + * See the GNU General Public License for more details. | ||
60 | + * | ||
61 | + * You should have received a copy of the GNU General Public License along | ||
62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
63 | + */ | 34 | + */ |
64 | +#ifndef HW_INTC_EXYNOS4210_GIC_H | 35 | +static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { |
65 | +#define HW_INTC_EXYNOS4210_GIC_H | 36 | + { .name = "CNTVCTSS", .cp = 15, .crm = 14, .opc1 = 9, |
66 | + | 37 | + .access = PL0_R, .type = ARM_CP_64BIT | ARM_CP_NO_RAW | ARM_CP_IO, |
67 | +#include "hw/sysbus.h" | 38 | + .accessfn = gt_vct_access, |
68 | + | 39 | + .readfn = gt_virt_cnt_read, .resetfn = arm_cp_reset_ignore, |
69 | +#define TYPE_EXYNOS4210_GIC "exynos4210.gic" | 40 | + }, |
70 | +OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | 41 | + { .name = "CNTVCTSS_EL0", .state = ARM_CP_STATE_AA64, |
71 | + | 42 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 6, |
72 | +#define EXYNOS4210_GIC_NCPUS 2 | 43 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, |
73 | + | 44 | + .accessfn = gt_vct_access, .readfn = gt_virt_cnt_read, |
74 | +struct Exynos4210GicState { | 45 | + }, |
75 | + SysBusDevice parent_obj; | 46 | + { .name = "CNTPCTSS", .cp = 15, .crm = 14, .opc1 = 8, |
76 | + | 47 | + .access = PL0_R, .type = ARM_CP_64BIT | ARM_CP_NO_RAW | ARM_CP_IO, |
77 | + MemoryRegion cpu_container; | 48 | + .accessfn = gt_pct_access, |
78 | + MemoryRegion dist_container; | 49 | + .readfn = gt_cnt_read, .resetfn = arm_cp_reset_ignore, |
79 | + MemoryRegion cpu_alias[EXYNOS4210_GIC_NCPUS]; | 50 | + }, |
80 | + MemoryRegion dist_alias[EXYNOS4210_GIC_NCPUS]; | 51 | + { .name = "CNTPCTSS_EL0", .state = ARM_CP_STATE_AA64, |
81 | + uint32_t num_cpu; | 52 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 5, |
82 | + DeviceState *gic; | 53 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, |
54 | + .accessfn = gt_pct_access, .readfn = gt_cnt_read, | ||
55 | + }, | ||
83 | +}; | 56 | +}; |
84 | + | 57 | + |
85 | +#endif | 58 | #else |
86 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 59 | |
87 | index XXXXXXX..XXXXXXX 100644 | 60 | /* |
88 | --- a/hw/arm/exynos4210.c | 61 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = { |
89 | +++ b/hw/arm/exynos4210.c | 62 | }, |
90 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | 63 | }; |
91 | sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL); | 64 | |
92 | 65 | +/* | |
93 | /* External GIC */ | 66 | + * CNTVCTSS_EL0 has the same trap conditions as CNTVCT_EL0, so it also |
94 | - dev = qdev_new("exynos4210.gic"); | 67 | + * is exposed to userspace by Linux. |
95 | - qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | 68 | + */ |
96 | - busdev = SYS_BUS_DEVICE(dev); | 69 | +static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { |
97 | - sysbus_realize_and_unref(busdev, &error_fatal); | 70 | + { .name = "CNTVCTSS_EL0", .state = ARM_CP_STATE_AA64, |
98 | + qdev_prop_set_uint32(DEVICE(&s->ext_gic), "num-cpu", EXYNOS4210_NCPUS); | 71 | + .opc0 = 3, .opc1 = 3, .crn = 14, .crm = 0, .opc2 = 6, |
99 | + busdev = SYS_BUS_DEVICE(&s->ext_gic); | 72 | + .access = PL0_R, .type = ARM_CP_NO_RAW | ARM_CP_IO, |
100 | + sysbus_realize(busdev, &error_fatal); | 73 | + .readfn = gt_virt_cnt_read, |
101 | /* Map CPU interface */ | 74 | + }, |
102 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_GIC_CPU_BASE_ADDR); | 75 | +}; |
103 | /* Map Distributer interface */ | 76 | + |
104 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | 77 | #endif |
105 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | 78 | |
79 | static void par_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
80 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) | ||
81 | if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { | ||
82 | define_arm_cp_regs(cpu, generic_timer_cp_reginfo); | ||
106 | } | 83 | } |
107 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | 84 | + if (cpu_isar_feature(aa64_ecv_traps, cpu)) { |
108 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); | 85 | + define_arm_cp_regs(cpu, gen_timer_ecv_cp_reginfo); |
109 | + s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); | 86 | + } |
110 | } | 87 | if (arm_feature(env, ARM_FEATURE_VAPA)) { |
111 | 88 | ARMCPRegInfo vapa_cp_reginfo[] = { | |
112 | /* Internal Interrupt Combiner */ | 89 | { .name = "PAR", .cp = 15, .crn = 7, .crm = 4, .opc1 = 0, .opc2 = 0, |
113 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
114 | } | ||
115 | |||
116 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
117 | + object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | ||
118 | } | ||
119 | |||
120 | static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
121 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
122 | index XXXXXXX..XXXXXXX 100644 | ||
123 | --- a/hw/intc/exynos4210_gic.c | ||
124 | +++ b/hw/intc/exynos4210_gic.c | ||
125 | @@ -XXX,XX +XXX,XX @@ | ||
126 | #include "qemu/module.h" | ||
127 | #include "hw/irq.h" | ||
128 | #include "hw/qdev-properties.h" | ||
129 | +#include "hw/intc/exynos4210_gic.h" | ||
130 | #include "hw/arm/exynos4210.h" | ||
131 | #include "qom/object.h" | ||
132 | |||
133 | @@ -XXX,XX +XXX,XX @@ | ||
134 | #define EXYNOS4210_GIC_CPU_REGION_SIZE 0x100 | ||
135 | #define EXYNOS4210_GIC_DIST_REGION_SIZE 0x1000 | ||
136 | |||
137 | -#define TYPE_EXYNOS4210_GIC "exynos4210.gic" | ||
138 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) | ||
139 | - | ||
140 | -struct Exynos4210GicState { | ||
141 | - SysBusDevice parent_obj; | ||
142 | - | ||
143 | - MemoryRegion cpu_container; | ||
144 | - MemoryRegion dist_container; | ||
145 | - MemoryRegion cpu_alias[EXYNOS4210_NCPUS]; | ||
146 | - MemoryRegion dist_alias[EXYNOS4210_NCPUS]; | ||
147 | - uint32_t num_cpu; | ||
148 | - DeviceState *gic; | ||
149 | -}; | ||
150 | - | ||
151 | static void exynos4210_gic_set_irq(void *opaque, int irq, int level) | ||
152 | { | ||
153 | Exynos4210GicState *s = (Exynos4210GicState *)opaque; | ||
154 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_realize(DeviceState *dev, Error **errp) | ||
155 | * enough room for the cpu numbers. gcc 9.2.1 on 32-bit x86 | ||
156 | * doesn't figure this out, otherwise and gives spurious warnings. | ||
157 | */ | ||
158 | - assert(n <= EXYNOS4210_NCPUS); | ||
159 | + assert(n <= EXYNOS4210_GIC_NCPUS); | ||
160 | for (i = 0; i < n; i++) { | ||
161 | /* Map CPU interface per SMP Core */ | ||
162 | sprintf(cpu_alias_name, "%s%x", cpu_prefix, i); | ||
163 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
164 | index XXXXXXX..XXXXXXX 100644 | ||
165 | --- a/MAINTAINERS | ||
166 | +++ b/MAINTAINERS | ||
167 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | ||
168 | L: qemu-arm@nongnu.org | ||
169 | S: Odd Fixes | ||
170 | F: hw/*/exynos* | ||
171 | -F: include/hw/arm/exynos4210.h | ||
172 | +F: include/hw/*/exynos* | ||
173 | |||
174 | Calxeda Highbank | ||
175 | M: Rob Herring <robh@kernel.org> | ||
176 | -- | 90 | -- |
177 | 2.25.1 | 91 | 2.34.1 | diff view generated by jsdifflib |
1 | The function exynos4210_combiner_get_gpioin() currently lives in | 1 | When ID_AA64MMFR0_EL1.ECV is 0b0010, a new register CNTPOFF_EL2 is |
---|---|---|---|
2 | exynos4210_combiner.c, but it isn't really part of the combiner | 2 | implemented. This is similar to the existing CNTVOFF_EL2, except |
3 | device itself -- it is a function that implements the wiring up of | 3 | that it controls a hypervisor-adjustable offset made to the physical |
4 | some interrupt sources to multiple combiner inputs. Move it to live | 4 | counter and timer. |
5 | with the other SoC-level code in exynos4210.c, along with a few | 5 | |
6 | macros previously defined in exynos4210.h which are now used only | 6 | Implement the handling for this register, which includes control/trap |
7 | in exynos4210.c. | 7 | bits in SCR_EL3 and CNTHCTL_EL2. |
8 | 8 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
11 | Message-id: 20220404154658.565020-11-peter.maydell@linaro.org | 11 | Message-id: 20240301183219.2424889-8-peter.maydell@linaro.org |
12 | --- | 12 | --- |
13 | include/hw/arm/exynos4210.h | 11 ----- | 13 | target/arm/cpu-features.h | 5 +++ |
14 | hw/arm/exynos4210.c | 82 +++++++++++++++++++++++++++++++++++ | 14 | target/arm/cpu.h | 1 + |
15 | hw/intc/exynos4210_combiner.c | 77 -------------------------------- | 15 | target/arm/helper.c | 68 +++++++++++++++++++++++++++++++++++++-- |
16 | 3 files changed, 82 insertions(+), 88 deletions(-) | 16 | target/arm/trace-events | 1 + |
17 | 4 files changed, 73 insertions(+), 2 deletions(-) | ||
17 | 18 | ||
18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 19 | diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h |
19 | index XXXXXXX..XXXXXXX 100644 | 20 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/include/hw/arm/exynos4210.h | 21 | --- a/target/arm/cpu-features.h |
21 | +++ b/include/hw/arm/exynos4210.h | 22 | +++ b/target/arm/cpu-features.h |
22 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ static inline bool isar_feature_aa64_ecv_traps(const ARMISARegisters *id) |
23 | #define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \ | 24 | return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 0; |
24 | (EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8) | ||
25 | |||
26 | -#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp)*8 + (bit)) | ||
27 | -#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8) | ||
28 | -#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | ||
29 | - ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | ||
30 | - | ||
31 | /* IRQs number for external and internal GIC */ | ||
32 | #define EXYNOS4210_EXT_GIC_NIRQ (160-32) | ||
33 | #define EXYNOS4210_INT_GIC_NIRQ 64 | ||
34 | @@ -XXX,XX +XXX,XX @@ void exynos4210_write_secondary(ARMCPU *cpu, | ||
35 | * bit - bit number inside group */ | ||
36 | uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit); | ||
37 | |||
38 | -/* | ||
39 | - * Get Combiner input GPIO into irqs structure | ||
40 | - */ | ||
41 | -void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, | ||
42 | - int ext); | ||
43 | - | ||
44 | /* | ||
45 | * exynos4210 UART | ||
46 | */ | ||
47 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/hw/arm/exynos4210.c | ||
50 | +++ b/hw/arm/exynos4210.c | ||
51 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
52 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
53 | }; | ||
54 | |||
55 | +#define EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit) ((grp) * 8 + (bit)) | ||
56 | +#define EXYNOS4210_COMBINER_GET_GRP_NUM(irq) ((irq) / 8) | ||
57 | +#define EXYNOS4210_COMBINER_GET_BIT_NUM(irq) \ | ||
58 | + ((irq) - 8 * EXYNOS4210_COMBINER_GET_GRP_NUM(irq)) | ||
59 | + | ||
60 | /* | ||
61 | * Initialize board IRQs. | ||
62 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs. | ||
63 | @@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
64 | return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
65 | } | 25 | } |
66 | 26 | ||
67 | +/* | 27 | +static inline bool isar_feature_aa64_ecv(const ARMISARegisters *id) |
68 | + * Get Combiner input GPIO into irqs structure | ||
69 | + */ | ||
70 | +static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
71 | + DeviceState *dev, int ext) | ||
72 | +{ | 28 | +{ |
73 | + int n; | 29 | + return FIELD_EX64(id->id_aa64mmfr0, ID_AA64MMFR0, ECV) > 1; |
74 | + int bit; | ||
75 | + int max; | ||
76 | + qemu_irq *irq; | ||
77 | + | ||
78 | + max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | ||
79 | + EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
80 | + irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
81 | + | ||
82 | + /* | ||
83 | + * Some IRQs of Int/External Combiner are going to two Combiners groups, | ||
84 | + * so let split them. | ||
85 | + */ | ||
86 | + for (n = 0; n < max; n++) { | ||
87 | + | ||
88 | + bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
89 | + | ||
90 | + switch (n) { | ||
91 | + /* MDNIE_LCD1 INTG1 */ | ||
92 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | ||
93 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | ||
94 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
95 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
96 | + continue; | ||
97 | + | ||
98 | + /* TMU INTG3 */ | ||
99 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
100 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
101 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
102 | + continue; | ||
103 | + | ||
104 | + /* LCD1 INTG12 */ | ||
105 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
106 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
107 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
108 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
109 | + continue; | ||
110 | + | ||
111 | + /* Multi-Core Timer INTG12 */ | ||
112 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
113 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
114 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
115 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
116 | + continue; | ||
117 | + | ||
118 | + /* Multi-Core Timer INTG35 */ | ||
119 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
120 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
121 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
122 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
123 | + continue; | ||
124 | + | ||
125 | + /* Multi-Core Timer INTG51 */ | ||
126 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
127 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
128 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
129 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
130 | + continue; | ||
131 | + | ||
132 | + /* Multi-Core Timer INTG53 */ | ||
133 | + case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
134 | + EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
135 | + irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
136 | + irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
137 | + continue; | ||
138 | + } | ||
139 | + | ||
140 | + irq[n] = qdev_get_gpio_in(dev, n); | ||
141 | + } | ||
142 | +} | 30 | +} |
143 | + | 31 | + |
144 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | 32 | static inline bool isar_feature_aa64_vh(const ARMISARegisters *id) |
145 | 0x09, 0x00, 0x00, 0x00 }; | 33 | { |
146 | 34 | return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, VH) != 0; | |
147 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c | 35 | diff --git a/target/arm/cpu.h b/target/arm/cpu.h |
148 | index XXXXXXX..XXXXXXX 100644 | 36 | index XXXXXXX..XXXXXXX 100644 |
149 | --- a/hw/intc/exynos4210_combiner.c | 37 | --- a/target/arm/cpu.h |
150 | +++ b/hw/intc/exynos4210_combiner.c | 38 | +++ b/target/arm/cpu.h |
151 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_exynos4210_combiner = { | 39 | @@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState { |
40 | uint64_t c14_cntkctl; /* Timer Control register */ | ||
41 | uint64_t cnthctl_el2; /* Counter/Timer Hyp Control register */ | ||
42 | uint64_t cntvoff_el2; /* Counter Virtual Offset register */ | ||
43 | + uint64_t cntpoff_el2; /* Counter Physical Offset register */ | ||
44 | ARMGenericTimer c14_timer[NUM_GTIMERS]; | ||
45 | uint32_t c15_cpar; /* XScale Coprocessor Access Register */ | ||
46 | uint32_t c15_ticonfig; /* TI925T configuration byte. */ | ||
47 | diff --git a/target/arm/helper.c b/target/arm/helper.c | ||
48 | index XXXXXXX..XXXXXXX 100644 | ||
49 | --- a/target/arm/helper.c | ||
50 | +++ b/target/arm/helper.c | ||
51 | @@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) | ||
52 | if (cpu_isar_feature(aa64_rme, cpu)) { | ||
53 | valid_mask |= SCR_NSE | SCR_GPF; | ||
54 | } | ||
55 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
56 | + valid_mask |= SCR_ECVEN; | ||
57 | + } | ||
58 | } else { | ||
59 | valid_mask &= ~(SCR_RW | SCR_ST); | ||
60 | if (cpu_isar_feature(aa32_ras, cpu)) { | ||
61 | @@ -XXX,XX +XXX,XX @@ void gt_rme_post_el_change(ARMCPU *cpu, void *ignored) | ||
62 | gt_update_irq(cpu, GTIMER_PHYS); | ||
63 | } | ||
64 | |||
65 | +static uint64_t gt_phys_raw_cnt_offset(CPUARMState *env) | ||
66 | +{ | ||
67 | + if ((env->cp15.scr_el3 & SCR_ECVEN) && | ||
68 | + FIELD_EX64(env->cp15.cnthctl_el2, CNTHCTL, ECV) && | ||
69 | + arm_is_el2_enabled(env) && | ||
70 | + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { | ||
71 | + return env->cp15.cntpoff_el2; | ||
72 | + } | ||
73 | + return 0; | ||
74 | +} | ||
75 | + | ||
76 | +static uint64_t gt_phys_cnt_offset(CPUARMState *env) | ||
77 | +{ | ||
78 | + if (arm_current_el(env) >= 2) { | ||
79 | + return 0; | ||
80 | + } | ||
81 | + return gt_phys_raw_cnt_offset(env); | ||
82 | +} | ||
83 | + | ||
84 | static void gt_recalc_timer(ARMCPU *cpu, int timeridx) | ||
85 | { | ||
86 | ARMGenericTimer *gt = &cpu->env.cp15.c14_timer[timeridx]; | ||
87 | @@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx) | ||
88 | * reset timer to when ISTATUS next has to change | ||
89 | */ | ||
90 | uint64_t offset = timeridx == GTIMER_VIRT ? | ||
91 | - cpu->env.cp15.cntvoff_el2 : 0; | ||
92 | + cpu->env.cp15.cntvoff_el2 : gt_phys_raw_cnt_offset(&cpu->env); | ||
93 | uint64_t count = gt_get_countervalue(&cpu->env); | ||
94 | /* Note that this must be unsigned 64 bit arithmetic: */ | ||
95 | int istatus = count - offset >= gt->cval; | ||
96 | @@ -XXX,XX +XXX,XX @@ static void gt_timer_reset(CPUARMState *env, const ARMCPRegInfo *ri, | ||
97 | |||
98 | static uint64_t gt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri) | ||
99 | { | ||
100 | - return gt_get_countervalue(env); | ||
101 | + return gt_get_countervalue(env) - gt_phys_cnt_offset(env); | ||
102 | } | ||
103 | |||
104 | static uint64_t gt_virt_cnt_offset(CPUARMState *env) | ||
105 | @@ -XXX,XX +XXX,XX @@ static uint64_t gt_tval_read(CPUARMState *env, const ARMCPRegInfo *ri, | ||
106 | case GTIMER_HYPVIRT: | ||
107 | offset = gt_virt_cnt_offset(env); | ||
108 | break; | ||
109 | + case GTIMER_PHYS: | ||
110 | + offset = gt_phys_cnt_offset(env); | ||
111 | + break; | ||
152 | } | 112 | } |
113 | |||
114 | return (uint32_t)(env->cp15.c14_timer[timeridx].cval - | ||
115 | @@ -XXX,XX +XXX,XX @@ static void gt_tval_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
116 | case GTIMER_HYPVIRT: | ||
117 | offset = gt_virt_cnt_offset(env); | ||
118 | break; | ||
119 | + case GTIMER_PHYS: | ||
120 | + offset = gt_phys_cnt_offset(env); | ||
121 | + break; | ||
122 | } | ||
123 | |||
124 | trace_arm_gt_tval_write(timeridx, value); | ||
125 | @@ -XXX,XX +XXX,XX @@ static void gt_cnthctl_write(CPUARMState *env, const ARMCPRegInfo *ri, | ||
126 | R_CNTHCTL_EL1NVVCT_MASK | | ||
127 | R_CNTHCTL_EVNTIS_MASK; | ||
128 | } | ||
129 | + if (cpu_isar_feature(aa64_ecv, cpu)) { | ||
130 | + valid_mask |= R_CNTHCTL_ECV_MASK; | ||
131 | + } | ||
132 | |||
133 | /* Clear RES0 bits */ | ||
134 | value &= valid_mask; | ||
135 | @@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo gen_timer_ecv_cp_reginfo[] = { | ||
136 | }, | ||
153 | }; | 137 | }; |
154 | 138 | ||
155 | -/* | 139 | +static CPAccessResult gt_cntpoff_access(CPUARMState *env, |
156 | - * Get Combiner input GPIO into irqs structure | 140 | + const ARMCPRegInfo *ri, |
157 | - */ | 141 | + bool isread) |
158 | -void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, | 142 | +{ |
159 | - int ext) | 143 | + if (arm_current_el(env) == 2 && !(env->cp15.scr_el3 & SCR_ECVEN)) { |
160 | -{ | 144 | + return CP_ACCESS_TRAP_EL3; |
161 | - int n; | 145 | + } |
162 | - int bit; | 146 | + return CP_ACCESS_OK; |
163 | - int max; | 147 | +} |
164 | - qemu_irq *irq; | 148 | + |
165 | - | 149 | +static void gt_cntpoff_write(CPUARMState *env, const ARMCPRegInfo *ri, |
166 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | 150 | + uint64_t value) |
167 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | 151 | +{ |
168 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | 152 | + ARMCPU *cpu = env_archcpu(env); |
169 | - | 153 | + |
170 | - /* | 154 | + trace_arm_gt_cntpoff_write(value); |
171 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, | 155 | + raw_write(env, ri, value); |
172 | - * so let split them. | 156 | + gt_recalc_timer(cpu, GTIMER_PHYS); |
173 | - */ | 157 | +} |
174 | - for (n = 0; n < max; n++) { | 158 | + |
175 | - | 159 | +static const ARMCPRegInfo gen_timer_cntpoff_reginfo = { |
176 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | 160 | + .name = "CNTPOFF_EL2", .state = ARM_CP_STATE_AA64, |
177 | - | 161 | + .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 0, .opc2 = 6, |
178 | - switch (n) { | 162 | + .access = PL2_RW, .type = ARM_CP_IO, .resetvalue = 0, |
179 | - /* MDNIE_LCD1 INTG1 */ | 163 | + .accessfn = gt_cntpoff_access, .writefn = gt_cntpoff_write, |
180 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | 164 | + .nv2_redirect_offset = 0x1a8, |
181 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | 165 | + .fieldoffset = offsetof(CPUARMState, cp15.cntpoff_el2), |
182 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | 166 | +}; |
183 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | 167 | #else |
184 | - continue; | 168 | |
185 | - | 169 | /* |
186 | - /* TMU INTG3 */ | 170 | @@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu) |
187 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | 171 | if (cpu_isar_feature(aa64_ecv_traps, cpu)) { |
188 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | 172 | define_arm_cp_regs(cpu, gen_timer_ecv_cp_reginfo); |
189 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | 173 | } |
190 | - continue; | 174 | +#ifndef CONFIG_USER_ONLY |
191 | - | 175 | + if (cpu_isar_feature(aa64_ecv, cpu)) { |
192 | - /* LCD1 INTG12 */ | 176 | + define_one_arm_cp_reg(cpu, &gen_timer_cntpoff_reginfo); |
193 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | 177 | + } |
194 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | 178 | +#endif |
195 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | 179 | if (arm_feature(env, ARM_FEATURE_VAPA)) { |
196 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | 180 | ARMCPRegInfo vapa_cp_reginfo[] = { |
197 | - continue; | 181 | { .name = "PAR", .cp = 15, .crn = 7, .crm = 4, .opc1 = 0, .opc2 = 0, |
198 | - | 182 | diff --git a/target/arm/trace-events b/target/arm/trace-events |
199 | - /* Multi-Core Timer INTG12 */ | 183 | index XXXXXXX..XXXXXXX 100644 |
200 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | 184 | --- a/target/arm/trace-events |
201 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | 185 | +++ b/target/arm/trace-events |
202 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | 186 | @@ -XXX,XX +XXX,XX @@ arm_gt_tval_write(int timer, uint64_t value) "gt_tval_write: timer %d value 0x%" |
203 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | 187 | arm_gt_ctl_write(int timer, uint64_t value) "gt_ctl_write: timer %d value 0x%" PRIx64 |
204 | - continue; | 188 | arm_gt_imask_toggle(int timer) "gt_ctl_write: timer %d IMASK toggle" |
205 | - | 189 | arm_gt_cntvoff_write(uint64_t value) "gt_cntvoff_write: value 0x%" PRIx64 |
206 | - /* Multi-Core Timer INTG35 */ | 190 | +arm_gt_cntpoff_write(uint64_t value) "gt_cntpoff_write: value 0x%" PRIx64 |
207 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | 191 | arm_gt_update_irq(int timer, int irqstate) "gt_update_irq: timer %d irqstate %d" |
208 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | 192 | |
209 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | 193 | # kvm.c |
210 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
211 | - continue; | ||
212 | - | ||
213 | - /* Multi-Core Timer INTG51 */ | ||
214 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 4) ... | ||
215 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(51, 8): | ||
216 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
217 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
218 | - continue; | ||
219 | - | ||
220 | - /* Multi-Core Timer INTG53 */ | ||
221 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 4) ... | ||
222 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(53, 8): | ||
223 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
224 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
225 | - continue; | ||
226 | - } | ||
227 | - | ||
228 | - irq[n] = qdev_get_gpio_in(dev, n); | ||
229 | - } | ||
230 | -} | ||
231 | - | ||
232 | static uint64_t | ||
233 | exynos4210_combiner_read(void *opaque, hwaddr offset, unsigned size) | ||
234 | { | ||
235 | -- | 194 | -- |
236 | 2.25.1 | 195 | 2.34.1 | diff view generated by jsdifflib |
1 | The only time we use the int_combiner_irq[] and ext_combiner_irq[] | 1 | Enable all FEAT_ECV features on the 'max' CPU. |
---|---|---|---|
2 | arrays in the Exynos4210Irq struct is during realize of the SoC -- we | ||
3 | initialize them with the input IRQs of the combiner devices, and then | ||
4 | connect those to outputs of other devices in | ||
5 | exynos4210_init_board_irqs(). Now that the combiner objects are | ||
6 | easily accessible as s->int_combiner and s->ext_combiner we can make | ||
7 | the connections directly from one device to the other without going | ||
8 | via these arrays. | ||
9 | |||
10 | Since these are the only two remaining elements of Exynos4210Irq, | ||
11 | we can remove that struct entirely. | ||
12 | 2 | ||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20220404154658.565020-19-peter.maydell@linaro.org | 6 | Message-id: 20240301183219.2424889-9-peter.maydell@linaro.org |
16 | --- | 7 | --- |
17 | include/hw/arm/exynos4210.h | 6 ------ | 8 | docs/system/arm/emulation.rst | 1 + |
18 | hw/arm/exynos4210.c | 34 ++++++++-------------------------- | 9 | target/arm/tcg/cpu64.c | 1 + |
19 | 2 files changed, 8 insertions(+), 32 deletions(-) | 10 | 2 files changed, 2 insertions(+) |
20 | 11 | ||
21 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 12 | diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst |
22 | index XXXXXXX..XXXXXXX 100644 | 13 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/include/hw/arm/exynos4210.h | 14 | --- a/docs/system/arm/emulation.rst |
24 | +++ b/include/hw/arm/exynos4210.h | 15 | +++ b/docs/system/arm/emulation.rst |
25 | @@ -XXX,XX +XXX,XX @@ | 16 | @@ -XXX,XX +XXX,XX @@ the following architecture extensions: |
26 | */ | 17 | - FEAT_DotProd (Advanced SIMD dot product instructions) |
27 | #define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38) | 18 | - FEAT_DoubleFault (Double Fault Extension) |
28 | 19 | - FEAT_E0PD (Preventing EL0 access to halves of address maps) | |
29 | -typedef struct Exynos4210Irq { | 20 | +- FEAT_ECV (Enhanced Counter Virtualization) |
30 | - qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | 21 | - FEAT_EPAC (Enhanced pointer authentication) |
31 | - qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | 22 | - FEAT_ETS (Enhanced Translation Synchronization) |
32 | -} Exynos4210Irq; | 23 | - FEAT_EVT (Enhanced Virtualization Traps) |
33 | - | 24 | diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c |
34 | struct Exynos4210State { | ||
35 | /*< private >*/ | ||
36 | SysBusDevice parent_obj; | ||
37 | /*< public >*/ | ||
38 | ARMCPU *cpu[EXYNOS4210_NCPUS]; | ||
39 | - Exynos4210Irq irqs; | ||
40 | qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
41 | |||
42 | MemoryRegion chipid_mem; | ||
43 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/hw/arm/exynos4210.c | 26 | --- a/target/arm/tcg/cpu64.c |
46 | +++ b/hw/arm/exynos4210.c | 27 | +++ b/target/arm/tcg/cpu64.c |
47 | @@ -XXX,XX +XXX,XX @@ static int mapline_size(const int *mapline) | 28 | @@ -XXX,XX +XXX,XX @@ void aarch64_max_tcg_initfn(Object *obj) |
48 | static void exynos4210_init_board_irqs(Exynos4210State *s) | 29 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 supported */ |
49 | { | 30 | t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 supported */ |
50 | uint32_t grp, bit, irq_id, n; | 31 | t = FIELD_DP64(t, ID_AA64MMFR0, FGT, 1); /* FEAT_FGT */ |
51 | - Exynos4210Irq *is = &s->irqs; | 32 | + t = FIELD_DP64(t, ID_AA64MMFR0, ECV, 2); /* FEAT_ECV */ |
52 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | 33 | cpu->isar.id_aa64mmfr0 = t; |
53 | + DeviceState *intcdev = DEVICE(&s->int_combiner); | 34 | |
54 | + DeviceState *extcdev = DEVICE(&s->ext_combiner); | 35 | t = cpu->isar.id_aa64mmfr1; |
55 | int splitcount = 0; | ||
56 | DeviceState *splitter; | ||
57 | const int *mapline; | ||
58 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
59 | splitin = 0; | ||
60 | for (;;) { | ||
61 | s->irq_table[in] = qdev_get_gpio_in(splitter, 0); | ||
62 | - qdev_connect_gpio_out(splitter, splitin, is->int_combiner_irq[in]); | ||
63 | - qdev_connect_gpio_out(splitter, splitin + 1, is->ext_combiner_irq[in]); | ||
64 | + qdev_connect_gpio_out(splitter, splitin, | ||
65 | + qdev_get_gpio_in(intcdev, in)); | ||
66 | + qdev_connect_gpio_out(splitter, splitin + 1, | ||
67 | + qdev_get_gpio_in(extcdev, in)); | ||
68 | splitin += 2; | ||
69 | if (!mapline) { | ||
70 | break; | ||
71 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
72 | qdev_realize(splitter, NULL, &error_abort); | ||
73 | splitcount++; | ||
74 | s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
75 | - qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
76 | + qdev_connect_gpio_out(splitter, 0, qdev_get_gpio_in(intcdev, n)); | ||
77 | qdev_connect_gpio_out(splitter, 1, | ||
78 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
79 | } else { | ||
80 | - s->irq_table[n] = is->int_combiner_irq[n]; | ||
81 | + s->irq_table[n] = qdev_get_gpio_in(intcdev, n); | ||
82 | } | ||
83 | } | ||
84 | /* | ||
85 | @@ -XXX,XX +XXX,XX @@ uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
86 | return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
87 | } | ||
88 | |||
89 | -/* | ||
90 | - * Get Combiner input GPIO into irqs structure | ||
91 | - */ | ||
92 | -static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
93 | - DeviceState *dev, int ext) | ||
94 | -{ | ||
95 | - int n; | ||
96 | - int max; | ||
97 | - qemu_irq *irq; | ||
98 | - | ||
99 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | ||
100 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
101 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
102 | - | ||
103 | - for (n = 0; n < max; n++) { | ||
104 | - irq[n] = qdev_get_gpio_in(dev, n); | ||
105 | - } | ||
106 | -} | ||
107 | - | ||
108 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
109 | 0x09, 0x00, 0x00, 0x00 }; | ||
110 | |||
111 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
112 | sysbus_connect_irq(busdev, n, | ||
113 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
114 | } | ||
115 | - exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0); | ||
116 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); | ||
117 | |||
118 | /* External Interrupt Combiner */ | ||
119 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
120 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
121 | sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
122 | } | ||
123 | - exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1); | ||
124 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
125 | |||
126 | /* Initialize board IRQs. */ | ||
127 | -- | 36 | -- |
128 | 2.25.1 | 37 | 2.34.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | 2 | ||
3 | Add a model of the Xilinx Versal CRL. | 3 | Features supported : |
4 | - the 8 STM32L4x5 GPIOs are initialized with their reset values | ||
5 | (except IDR, see below) | ||
6 | - input mode : setting a pin in input mode "externally" (using input | ||
7 | irqs) results in an out irq (transmitted to SYSCFG) | ||
8 | - output mode : setting a bit in ODR sets the corresponding out irq | ||
9 | (if this line is configured in output mode) | ||
10 | - pull-up, pull-down | ||
11 | - push-pull, open-drain | ||
4 | 12 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | 13 | Difference with the real GPIOs : |
6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> | 14 | - Alternate Function and Analog mode aren't implemented : |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | 15 | pins in AF/Analog behave like pins in input mode |
8 | Message-id: 20220406174303.2022038-4-edgar.iglesias@xilinx.com | 16 | - floating pins stay at their last value |
17 | - register IDR reset values differ from the real one : | ||
18 | values are coherent with the other registers reset values | ||
19 | and the fact that AF/Analog modes aren't implemented | ||
20 | - setting I/O output speed isn't supported | ||
21 | - locking port bits isn't supported | ||
22 | - ADC function isn't supported | ||
23 | - GPIOH has 16 pins instead of 2 pins | ||
24 | - writing to registers LCKR, AFRL, AFRH and ASCR is ineffective | ||
25 | |||
26 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
27 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
28 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
29 | Acked-by: Alistair Francis <alistair.francis@wdc.com> | ||
30 | Message-id: 20240305210444.310665-2-ines.varhol@telecom-paris.fr | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 31 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 32 | --- |
11 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++ | 33 | MAINTAINERS | 1 + |
12 | hw/misc/xlnx-versal-crl.c | 421 ++++++++++++++++++++++++++++++ | 34 | docs/system/arm/b-l475e-iot01a.rst | 2 +- |
13 | hw/misc/meson.build | 1 + | 35 | include/hw/gpio/stm32l4x5_gpio.h | 70 +++++ |
14 | 3 files changed, 657 insertions(+) | 36 | hw/gpio/stm32l4x5_gpio.c | 477 +++++++++++++++++++++++++++++ |
15 | create mode 100644 include/hw/misc/xlnx-versal-crl.h | 37 | hw/gpio/Kconfig | 3 + |
16 | create mode 100644 hw/misc/xlnx-versal-crl.c | 38 | hw/gpio/meson.build | 1 + |
39 | hw/gpio/trace-events | 6 + | ||
40 | 7 files changed, 559 insertions(+), 1 deletion(-) | ||
41 | create mode 100644 include/hw/gpio/stm32l4x5_gpio.h | ||
42 | create mode 100644 hw/gpio/stm32l4x5_gpio.c | ||
17 | 43 | ||
18 | diff --git a/include/hw/misc/xlnx-versal-crl.h b/include/hw/misc/xlnx-versal-crl.h | 44 | diff --git a/MAINTAINERS b/MAINTAINERS |
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/MAINTAINERS | ||
47 | +++ b/MAINTAINERS | ||
48 | @@ -XXX,XX +XXX,XX @@ F: hw/arm/stm32l4x5_soc.c | ||
49 | F: hw/misc/stm32l4x5_exti.c | ||
50 | F: hw/misc/stm32l4x5_syscfg.c | ||
51 | F: hw/misc/stm32l4x5_rcc.c | ||
52 | +F: hw/gpio/stm32l4x5_gpio.c | ||
53 | F: include/hw/*/stm32l4x5_*.h | ||
54 | |||
55 | B-L475E-IOT01A IoT Node | ||
56 | diff --git a/docs/system/arm/b-l475e-iot01a.rst b/docs/system/arm/b-l475e-iot01a.rst | ||
57 | index XXXXXXX..XXXXXXX 100644 | ||
58 | --- a/docs/system/arm/b-l475e-iot01a.rst | ||
59 | +++ b/docs/system/arm/b-l475e-iot01a.rst | ||
60 | @@ -XXX,XX +XXX,XX @@ Currently B-L475E-IOT01A machine's only supports the following devices: | ||
61 | - STM32L4x5 EXTI (Extended interrupts and events controller) | ||
62 | - STM32L4x5 SYSCFG (System configuration controller) | ||
63 | - STM32L4x5 RCC (Reset and clock control) | ||
64 | +- STM32L4x5 GPIOs (General-purpose I/Os) | ||
65 | |||
66 | Missing devices | ||
67 | """"""""""""""" | ||
68 | @@ -XXX,XX +XXX,XX @@ Missing devices | ||
69 | The B-L475E-IOT01A does *not* support the following devices: | ||
70 | |||
71 | - Serial ports (UART) | ||
72 | -- General-purpose I/Os (GPIO) | ||
73 | - Analog to Digital Converter (ADC) | ||
74 | - SPI controller | ||
75 | - Timer controller (TIMER) | ||
76 | diff --git a/include/hw/gpio/stm32l4x5_gpio.h b/include/hw/gpio/stm32l4x5_gpio.h | ||
19 | new file mode 100644 | 77 | new file mode 100644 |
20 | index XXXXXXX..XXXXXXX | 78 | index XXXXXXX..XXXXXXX |
21 | --- /dev/null | 79 | --- /dev/null |
22 | +++ b/include/hw/misc/xlnx-versal-crl.h | 80 | +++ b/include/hw/gpio/stm32l4x5_gpio.h |
23 | @@ -XXX,XX +XXX,XX @@ | 81 | @@ -XXX,XX +XXX,XX @@ |
24 | +/* | 82 | +/* |
25 | + * QEMU model of the Clock-Reset-LPD (CRL). | 83 | + * STM32L4x5 GPIO (General Purpose Input/Ouput) |
26 | + * | 84 | + * |
27 | + * Copyright (c) 2022 Xilinx Inc. | 85 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
86 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
87 | + * | ||
28 | + * SPDX-License-Identifier: GPL-2.0-or-later | 88 | + * SPDX-License-Identifier: GPL-2.0-or-later |
29 | + * | 89 | + * |
30 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> | 90 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
91 | + * See the COPYING file in the top-level directory. | ||
31 | + */ | 92 | + */ |
32 | +#ifndef HW_MISC_XLNX_VERSAL_CRL_H | 93 | + |
33 | +#define HW_MISC_XLNX_VERSAL_CRL_H | 94 | +/* |
95 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
96 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
97 | + * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html | ||
98 | + */ | ||
99 | + | ||
100 | +#ifndef HW_STM32L4X5_GPIO_H | ||
101 | +#define HW_STM32L4X5_GPIO_H | ||
34 | + | 102 | + |
35 | +#include "hw/sysbus.h" | 103 | +#include "hw/sysbus.h" |
36 | +#include "hw/register.h" | 104 | +#include "qom/object.h" |
37 | +#include "target/arm/cpu.h" | 105 | + |
38 | + | 106 | +#define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio" |
39 | +#define TYPE_XLNX_VERSAL_CRL "xlnx,versal-crl" | 107 | +OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO) |
40 | +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCRL, XLNX_VERSAL_CRL) | 108 | + |
41 | + | 109 | +#define GPIO_NUM_PINS 16 |
42 | +REG32(ERR_CTRL, 0x0) | 110 | + |
43 | + FIELD(ERR_CTRL, SLVERR_ENABLE, 0, 1) | 111 | +struct Stm32l4x5GpioState { |
44 | +REG32(IR_STATUS, 0x4) | ||
45 | + FIELD(IR_STATUS, ADDR_DECODE_ERR, 0, 1) | ||
46 | +REG32(IR_MASK, 0x8) | ||
47 | + FIELD(IR_MASK, ADDR_DECODE_ERR, 0, 1) | ||
48 | +REG32(IR_ENABLE, 0xc) | ||
49 | + FIELD(IR_ENABLE, ADDR_DECODE_ERR, 0, 1) | ||
50 | +REG32(IR_DISABLE, 0x10) | ||
51 | + FIELD(IR_DISABLE, ADDR_DECODE_ERR, 0, 1) | ||
52 | +REG32(WPROT, 0x1c) | ||
53 | + FIELD(WPROT, ACTIVE, 0, 1) | ||
54 | +REG32(PLL_CLK_OTHER_DMN, 0x20) | ||
55 | + FIELD(PLL_CLK_OTHER_DMN, APLL_BYPASS, 0, 1) | ||
56 | +REG32(RPLL_CTRL, 0x40) | ||
57 | + FIELD(RPLL_CTRL, POST_SRC, 24, 3) | ||
58 | + FIELD(RPLL_CTRL, PRE_SRC, 20, 3) | ||
59 | + FIELD(RPLL_CTRL, CLKOUTDIV, 16, 2) | ||
60 | + FIELD(RPLL_CTRL, FBDIV, 8, 8) | ||
61 | + FIELD(RPLL_CTRL, BYPASS, 3, 1) | ||
62 | + FIELD(RPLL_CTRL, RESET, 0, 1) | ||
63 | +REG32(RPLL_CFG, 0x44) | ||
64 | + FIELD(RPLL_CFG, LOCK_DLY, 25, 7) | ||
65 | + FIELD(RPLL_CFG, LOCK_CNT, 13, 10) | ||
66 | + FIELD(RPLL_CFG, LFHF, 10, 2) | ||
67 | + FIELD(RPLL_CFG, CP, 5, 4) | ||
68 | + FIELD(RPLL_CFG, RES, 0, 4) | ||
69 | +REG32(RPLL_FRAC_CFG, 0x48) | ||
70 | + FIELD(RPLL_FRAC_CFG, ENABLED, 31, 1) | ||
71 | + FIELD(RPLL_FRAC_CFG, SEED, 22, 3) | ||
72 | + FIELD(RPLL_FRAC_CFG, ALGRTHM, 19, 1) | ||
73 | + FIELD(RPLL_FRAC_CFG, ORDER, 18, 1) | ||
74 | + FIELD(RPLL_FRAC_CFG, DATA, 0, 16) | ||
75 | +REG32(PLL_STATUS, 0x50) | ||
76 | + FIELD(PLL_STATUS, RPLL_STABLE, 2, 1) | ||
77 | + FIELD(PLL_STATUS, RPLL_LOCK, 0, 1) | ||
78 | +REG32(RPLL_TO_XPD_CTRL, 0x100) | ||
79 | + FIELD(RPLL_TO_XPD_CTRL, CLKACT, 25, 1) | ||
80 | + FIELD(RPLL_TO_XPD_CTRL, DIVISOR0, 8, 10) | ||
81 | +REG32(LPD_TOP_SWITCH_CTRL, 0x104) | ||
82 | + FIELD(LPD_TOP_SWITCH_CTRL, CLKACT_ADMA, 26, 1) | ||
83 | + FIELD(LPD_TOP_SWITCH_CTRL, CLKACT, 25, 1) | ||
84 | + FIELD(LPD_TOP_SWITCH_CTRL, DIVISOR0, 8, 10) | ||
85 | + FIELD(LPD_TOP_SWITCH_CTRL, SRCSEL, 0, 3) | ||
86 | +REG32(LPD_LSBUS_CTRL, 0x108) | ||
87 | + FIELD(LPD_LSBUS_CTRL, CLKACT, 25, 1) | ||
88 | + FIELD(LPD_LSBUS_CTRL, DIVISOR0, 8, 10) | ||
89 | + FIELD(LPD_LSBUS_CTRL, SRCSEL, 0, 3) | ||
90 | +REG32(CPU_R5_CTRL, 0x10c) | ||
91 | + FIELD(CPU_R5_CTRL, CLKACT_OCM2, 28, 1) | ||
92 | + FIELD(CPU_R5_CTRL, CLKACT_OCM, 27, 1) | ||
93 | + FIELD(CPU_R5_CTRL, CLKACT_CORE, 26, 1) | ||
94 | + FIELD(CPU_R5_CTRL, CLKACT, 25, 1) | ||
95 | + FIELD(CPU_R5_CTRL, DIVISOR0, 8, 10) | ||
96 | + FIELD(CPU_R5_CTRL, SRCSEL, 0, 3) | ||
97 | +REG32(IOU_SWITCH_CTRL, 0x114) | ||
98 | + FIELD(IOU_SWITCH_CTRL, CLKACT, 25, 1) | ||
99 | + FIELD(IOU_SWITCH_CTRL, DIVISOR0, 8, 10) | ||
100 | + FIELD(IOU_SWITCH_CTRL, SRCSEL, 0, 3) | ||
101 | +REG32(GEM0_REF_CTRL, 0x118) | ||
102 | + FIELD(GEM0_REF_CTRL, CLKACT_RX, 27, 1) | ||
103 | + FIELD(GEM0_REF_CTRL, CLKACT_TX, 26, 1) | ||
104 | + FIELD(GEM0_REF_CTRL, CLKACT, 25, 1) | ||
105 | + FIELD(GEM0_REF_CTRL, DIVISOR0, 8, 10) | ||
106 | + FIELD(GEM0_REF_CTRL, SRCSEL, 0, 3) | ||
107 | +REG32(GEM1_REF_CTRL, 0x11c) | ||
108 | + FIELD(GEM1_REF_CTRL, CLKACT_RX, 27, 1) | ||
109 | + FIELD(GEM1_REF_CTRL, CLKACT_TX, 26, 1) | ||
110 | + FIELD(GEM1_REF_CTRL, CLKACT, 25, 1) | ||
111 | + FIELD(GEM1_REF_CTRL, DIVISOR0, 8, 10) | ||
112 | + FIELD(GEM1_REF_CTRL, SRCSEL, 0, 3) | ||
113 | +REG32(GEM_TSU_REF_CTRL, 0x120) | ||
114 | + FIELD(GEM_TSU_REF_CTRL, CLKACT, 25, 1) | ||
115 | + FIELD(GEM_TSU_REF_CTRL, DIVISOR0, 8, 10) | ||
116 | + FIELD(GEM_TSU_REF_CTRL, SRCSEL, 0, 3) | ||
117 | +REG32(USB0_BUS_REF_CTRL, 0x124) | ||
118 | + FIELD(USB0_BUS_REF_CTRL, CLKACT, 25, 1) | ||
119 | + FIELD(USB0_BUS_REF_CTRL, DIVISOR0, 8, 10) | ||
120 | + FIELD(USB0_BUS_REF_CTRL, SRCSEL, 0, 3) | ||
121 | +REG32(UART0_REF_CTRL, 0x128) | ||
122 | + FIELD(UART0_REF_CTRL, CLKACT, 25, 1) | ||
123 | + FIELD(UART0_REF_CTRL, DIVISOR0, 8, 10) | ||
124 | + FIELD(UART0_REF_CTRL, SRCSEL, 0, 3) | ||
125 | +REG32(UART1_REF_CTRL, 0x12c) | ||
126 | + FIELD(UART1_REF_CTRL, CLKACT, 25, 1) | ||
127 | + FIELD(UART1_REF_CTRL, DIVISOR0, 8, 10) | ||
128 | + FIELD(UART1_REF_CTRL, SRCSEL, 0, 3) | ||
129 | +REG32(SPI0_REF_CTRL, 0x130) | ||
130 | + FIELD(SPI0_REF_CTRL, CLKACT, 25, 1) | ||
131 | + FIELD(SPI0_REF_CTRL, DIVISOR0, 8, 10) | ||
132 | + FIELD(SPI0_REF_CTRL, SRCSEL, 0, 3) | ||
133 | +REG32(SPI1_REF_CTRL, 0x134) | ||
134 | + FIELD(SPI1_REF_CTRL, CLKACT, 25, 1) | ||
135 | + FIELD(SPI1_REF_CTRL, DIVISOR0, 8, 10) | ||
136 | + FIELD(SPI1_REF_CTRL, SRCSEL, 0, 3) | ||
137 | +REG32(CAN0_REF_CTRL, 0x138) | ||
138 | + FIELD(CAN0_REF_CTRL, CLKACT, 25, 1) | ||
139 | + FIELD(CAN0_REF_CTRL, DIVISOR0, 8, 10) | ||
140 | + FIELD(CAN0_REF_CTRL, SRCSEL, 0, 3) | ||
141 | +REG32(CAN1_REF_CTRL, 0x13c) | ||
142 | + FIELD(CAN1_REF_CTRL, CLKACT, 25, 1) | ||
143 | + FIELD(CAN1_REF_CTRL, DIVISOR0, 8, 10) | ||
144 | + FIELD(CAN1_REF_CTRL, SRCSEL, 0, 3) | ||
145 | +REG32(I2C0_REF_CTRL, 0x140) | ||
146 | + FIELD(I2C0_REF_CTRL, CLKACT, 25, 1) | ||
147 | + FIELD(I2C0_REF_CTRL, DIVISOR0, 8, 10) | ||
148 | + FIELD(I2C0_REF_CTRL, SRCSEL, 0, 3) | ||
149 | +REG32(I2C1_REF_CTRL, 0x144) | ||
150 | + FIELD(I2C1_REF_CTRL, CLKACT, 25, 1) | ||
151 | + FIELD(I2C1_REF_CTRL, DIVISOR0, 8, 10) | ||
152 | + FIELD(I2C1_REF_CTRL, SRCSEL, 0, 3) | ||
153 | +REG32(DBG_LPD_CTRL, 0x148) | ||
154 | + FIELD(DBG_LPD_CTRL, CLKACT, 25, 1) | ||
155 | + FIELD(DBG_LPD_CTRL, DIVISOR0, 8, 10) | ||
156 | + FIELD(DBG_LPD_CTRL, SRCSEL, 0, 3) | ||
157 | +REG32(TIMESTAMP_REF_CTRL, 0x14c) | ||
158 | + FIELD(TIMESTAMP_REF_CTRL, CLKACT, 25, 1) | ||
159 | + FIELD(TIMESTAMP_REF_CTRL, DIVISOR0, 8, 10) | ||
160 | + FIELD(TIMESTAMP_REF_CTRL, SRCSEL, 0, 3) | ||
161 | +REG32(CRL_SAFETY_CHK, 0x150) | ||
162 | +REG32(PSM_REF_CTRL, 0x154) | ||
163 | + FIELD(PSM_REF_CTRL, DIVISOR0, 8, 10) | ||
164 | + FIELD(PSM_REF_CTRL, SRCSEL, 0, 3) | ||
165 | +REG32(DBG_TSTMP_CTRL, 0x158) | ||
166 | + FIELD(DBG_TSTMP_CTRL, CLKACT, 25, 1) | ||
167 | + FIELD(DBG_TSTMP_CTRL, DIVISOR0, 8, 10) | ||
168 | + FIELD(DBG_TSTMP_CTRL, SRCSEL, 0, 3) | ||
169 | +REG32(CPM_TOPSW_REF_CTRL, 0x15c) | ||
170 | + FIELD(CPM_TOPSW_REF_CTRL, CLKACT, 25, 1) | ||
171 | + FIELD(CPM_TOPSW_REF_CTRL, DIVISOR0, 8, 10) | ||
172 | + FIELD(CPM_TOPSW_REF_CTRL, SRCSEL, 0, 3) | ||
173 | +REG32(USB3_DUAL_REF_CTRL, 0x160) | ||
174 | + FIELD(USB3_DUAL_REF_CTRL, CLKACT, 25, 1) | ||
175 | + FIELD(USB3_DUAL_REF_CTRL, DIVISOR0, 8, 10) | ||
176 | + FIELD(USB3_DUAL_REF_CTRL, SRCSEL, 0, 3) | ||
177 | +REG32(RST_CPU_R5, 0x300) | ||
178 | + FIELD(RST_CPU_R5, RESET_PGE, 4, 1) | ||
179 | + FIELD(RST_CPU_R5, RESET_AMBA, 2, 1) | ||
180 | + FIELD(RST_CPU_R5, RESET_CPU1, 1, 1) | ||
181 | + FIELD(RST_CPU_R5, RESET_CPU0, 0, 1) | ||
182 | +REG32(RST_ADMA, 0x304) | ||
183 | + FIELD(RST_ADMA, RESET, 0, 1) | ||
184 | +REG32(RST_GEM0, 0x308) | ||
185 | + FIELD(RST_GEM0, RESET, 0, 1) | ||
186 | +REG32(RST_GEM1, 0x30c) | ||
187 | + FIELD(RST_GEM1, RESET, 0, 1) | ||
188 | +REG32(RST_SPARE, 0x310) | ||
189 | + FIELD(RST_SPARE, RESET, 0, 1) | ||
190 | +REG32(RST_USB0, 0x314) | ||
191 | + FIELD(RST_USB0, RESET, 0, 1) | ||
192 | +REG32(RST_UART0, 0x318) | ||
193 | + FIELD(RST_UART0, RESET, 0, 1) | ||
194 | +REG32(RST_UART1, 0x31c) | ||
195 | + FIELD(RST_UART1, RESET, 0, 1) | ||
196 | +REG32(RST_SPI0, 0x320) | ||
197 | + FIELD(RST_SPI0, RESET, 0, 1) | ||
198 | +REG32(RST_SPI1, 0x324) | ||
199 | + FIELD(RST_SPI1, RESET, 0, 1) | ||
200 | +REG32(RST_CAN0, 0x328) | ||
201 | + FIELD(RST_CAN0, RESET, 0, 1) | ||
202 | +REG32(RST_CAN1, 0x32c) | ||
203 | + FIELD(RST_CAN1, RESET, 0, 1) | ||
204 | +REG32(RST_I2C0, 0x330) | ||
205 | + FIELD(RST_I2C0, RESET, 0, 1) | ||
206 | +REG32(RST_I2C1, 0x334) | ||
207 | + FIELD(RST_I2C1, RESET, 0, 1) | ||
208 | +REG32(RST_DBG_LPD, 0x338) | ||
209 | + FIELD(RST_DBG_LPD, RPU_DBG1_RESET, 5, 1) | ||
210 | + FIELD(RST_DBG_LPD, RPU_DBG0_RESET, 4, 1) | ||
211 | + FIELD(RST_DBG_LPD, RESET_HSDP, 1, 1) | ||
212 | + FIELD(RST_DBG_LPD, RESET, 0, 1) | ||
213 | +REG32(RST_GPIO, 0x33c) | ||
214 | + FIELD(RST_GPIO, RESET, 0, 1) | ||
215 | +REG32(RST_TTC, 0x344) | ||
216 | + FIELD(RST_TTC, TTC3_RESET, 3, 1) | ||
217 | + FIELD(RST_TTC, TTC2_RESET, 2, 1) | ||
218 | + FIELD(RST_TTC, TTC1_RESET, 1, 1) | ||
219 | + FIELD(RST_TTC, TTC0_RESET, 0, 1) | ||
220 | +REG32(RST_TIMESTAMP, 0x348) | ||
221 | + FIELD(RST_TIMESTAMP, RESET, 0, 1) | ||
222 | +REG32(RST_SWDT, 0x34c) | ||
223 | + FIELD(RST_SWDT, RESET, 0, 1) | ||
224 | +REG32(RST_OCM, 0x350) | ||
225 | + FIELD(RST_OCM, RESET, 0, 1) | ||
226 | +REG32(RST_IPI, 0x354) | ||
227 | + FIELD(RST_IPI, RESET, 0, 1) | ||
228 | +REG32(RST_SYSMON, 0x358) | ||
229 | + FIELD(RST_SYSMON, SEQ_RST, 1, 1) | ||
230 | + FIELD(RST_SYSMON, CFG_RST, 0, 1) | ||
231 | +REG32(RST_FPD, 0x360) | ||
232 | + FIELD(RST_FPD, SRST, 1, 1) | ||
233 | + FIELD(RST_FPD, POR, 0, 1) | ||
234 | +REG32(PSM_RST_MODE, 0x370) | ||
235 | + FIELD(PSM_RST_MODE, WAKEUP, 2, 1) | ||
236 | + FIELD(PSM_RST_MODE, RST_MODE, 0, 2) | ||
237 | + | ||
238 | +#define CRL_R_MAX (R_PSM_RST_MODE + 1) | ||
239 | + | ||
240 | +#define RPU_MAX_CPU 2 | ||
241 | + | ||
242 | +struct XlnxVersalCRL { | ||
243 | + SysBusDevice parent_obj; | 112 | + SysBusDevice parent_obj; |
244 | + qemu_irq irq; | 113 | + |
245 | + | 114 | + MemoryRegion mmio; |
246 | + struct { | 115 | + |
247 | + ARMCPU *cpu_r5[RPU_MAX_CPU]; | 116 | + /* GPIO registers */ |
248 | + DeviceState *adma[8]; | 117 | + uint32_t moder; |
249 | + DeviceState *uart[2]; | 118 | + uint32_t otyper; |
250 | + DeviceState *gem[2]; | 119 | + uint32_t ospeedr; |
251 | + DeviceState *usb; | 120 | + uint32_t pupdr; |
252 | + } cfg; | 121 | + uint32_t idr; |
253 | + | 122 | + uint32_t odr; |
254 | + RegisterInfoArray *reg_array; | 123 | + uint32_t lckr; |
255 | + uint32_t regs[CRL_R_MAX]; | 124 | + uint32_t afrl; |
256 | + RegisterInfo regs_info[CRL_R_MAX]; | 125 | + uint32_t afrh; |
126 | + uint32_t ascr; | ||
127 | + | ||
128 | + /* GPIO registers reset values */ | ||
129 | + uint32_t moder_reset; | ||
130 | + uint32_t ospeedr_reset; | ||
131 | + uint32_t pupdr_reset; | ||
132 | + | ||
133 | + /* | ||
134 | + * External driving of pins. | ||
135 | + * The pins can be set externally through the device | ||
136 | + * anonymous input GPIOs lines under certain conditions. | ||
137 | + * The pin must not be in push-pull output mode, | ||
138 | + * and can't be set high in open-drain mode. | ||
139 | + * Pins driven externally and configured to | ||
140 | + * output mode will in general be "disconnected" | ||
141 | + * (see `get_gpio_pinmask_to_disconnect()`) | ||
142 | + */ | ||
143 | + uint16_t disconnected_pins; | ||
144 | + uint16_t pins_connected_high; | ||
145 | + | ||
146 | + char *name; | ||
147 | + Clock *clk; | ||
148 | + qemu_irq pin[GPIO_NUM_PINS]; | ||
257 | +}; | 149 | +}; |
150 | + | ||
258 | +#endif | 151 | +#endif |
259 | diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c | 152 | diff --git a/hw/gpio/stm32l4x5_gpio.c b/hw/gpio/stm32l4x5_gpio.c |
260 | new file mode 100644 | 153 | new file mode 100644 |
261 | index XXXXXXX..XXXXXXX | 154 | index XXXXXXX..XXXXXXX |
262 | --- /dev/null | 155 | --- /dev/null |
263 | +++ b/hw/misc/xlnx-versal-crl.c | 156 | +++ b/hw/gpio/stm32l4x5_gpio.c |
264 | @@ -XXX,XX +XXX,XX @@ | 157 | @@ -XXX,XX +XXX,XX @@ |
265 | +/* | 158 | +/* |
266 | + * QEMU model of the Clock-Reset-LPD (CRL). | 159 | + * STM32L4x5 GPIO (General Purpose Input/Ouput) |
267 | + * | 160 | + * |
268 | + * Copyright (c) 2022 Advanced Micro Devices, Inc. | 161 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
162 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> | ||
163 | + * | ||
269 | + * SPDX-License-Identifier: GPL-2.0-or-later | 164 | + * SPDX-License-Identifier: GPL-2.0-or-later |
270 | + * | 165 | + * |
271 | + * Written by Edgar E. Iglesias <edgar.iglesias@amd.com> | 166 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
167 | + * See the COPYING file in the top-level directory. | ||
272 | + */ | 168 | + */ |
273 | + | 169 | + |
170 | +/* | ||
171 | + * The reference used is the STMicroElectronics RM0351 Reference manual | ||
172 | + * for STM32L4x5 and STM32L4x6 advanced Arm ® -based 32-bit MCUs. | ||
173 | + * https://www.st.com/en/microcontrollers-microprocessors/stm32l4x5/documentation.html | ||
174 | + */ | ||
175 | + | ||
274 | +#include "qemu/osdep.h" | 176 | +#include "qemu/osdep.h" |
177 | +#include "qemu/log.h" | ||
178 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
179 | +#include "hw/irq.h" | ||
180 | +#include "hw/qdev-clock.h" | ||
181 | +#include "hw/qdev-properties.h" | ||
182 | +#include "qapi/visitor.h" | ||
275 | +#include "qapi/error.h" | 183 | +#include "qapi/error.h" |
276 | +#include "qemu/log.h" | ||
277 | +#include "qemu/bitops.h" | ||
278 | +#include "migration/vmstate.h" | 184 | +#include "migration/vmstate.h" |
279 | +#include "hw/qdev-properties.h" | 185 | +#include "trace.h" |
280 | +#include "hw/sysbus.h" | 186 | + |
281 | +#include "hw/irq.h" | 187 | +#define GPIO_MODER 0x00 |
282 | +#include "hw/register.h" | 188 | +#define GPIO_OTYPER 0x04 |
283 | +#include "hw/resettable.h" | 189 | +#define GPIO_OSPEEDR 0x08 |
284 | + | 190 | +#define GPIO_PUPDR 0x0C |
285 | +#include "target/arm/arm-powerctl.h" | 191 | +#define GPIO_IDR 0x10 |
286 | +#include "hw/misc/xlnx-versal-crl.h" | 192 | +#define GPIO_ODR 0x14 |
287 | + | 193 | +#define GPIO_BSRR 0x18 |
288 | +#ifndef XLNX_VERSAL_CRL_ERR_DEBUG | 194 | +#define GPIO_LCKR 0x1C |
289 | +#define XLNX_VERSAL_CRL_ERR_DEBUG 0 | 195 | +#define GPIO_AFRL 0x20 |
290 | +#endif | 196 | +#define GPIO_AFRH 0x24 |
291 | + | 197 | +#define GPIO_BRR 0x28 |
292 | +static void crl_update_irq(XlnxVersalCRL *s) | 198 | +#define GPIO_ASCR 0x2C |
293 | +{ | 199 | + |
294 | + bool pending = s->regs[R_IR_STATUS] & ~s->regs[R_IR_MASK]; | 200 | +/* 0b11111111_11111111_00000000_00000000 */ |
295 | + qemu_set_irq(s->irq, pending); | 201 | +#define RESERVED_BITS_MASK 0xFFFF0000 |
296 | +} | 202 | + |
297 | + | 203 | +static void update_gpio_idr(Stm32l4x5GpioState *s); |
298 | +static void crl_status_postw(RegisterInfo *reg, uint64_t val64) | 204 | + |
299 | +{ | 205 | +static bool is_pull_up(Stm32l4x5GpioState *s, unsigned pin) |
300 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 206 | +{ |
301 | + crl_update_irq(s); | 207 | + return extract32(s->pupdr, 2 * pin, 2) == 1; |
302 | +} | 208 | +} |
303 | + | 209 | + |
304 | +static uint64_t crl_enable_prew(RegisterInfo *reg, uint64_t val64) | 210 | +static bool is_pull_down(Stm32l4x5GpioState *s, unsigned pin) |
305 | +{ | 211 | +{ |
306 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 212 | + return extract32(s->pupdr, 2 * pin, 2) == 2; |
307 | + uint32_t val = val64; | 213 | +} |
308 | + | 214 | + |
309 | + s->regs[R_IR_MASK] &= ~val; | 215 | +static bool is_output(Stm32l4x5GpioState *s, unsigned pin) |
310 | + crl_update_irq(s); | 216 | +{ |
311 | + return 0; | 217 | + return extract32(s->moder, 2 * pin, 2) == 1; |
312 | +} | 218 | +} |
313 | + | 219 | + |
314 | +static uint64_t crl_disable_prew(RegisterInfo *reg, uint64_t val64) | 220 | +static bool is_open_drain(Stm32l4x5GpioState *s, unsigned pin) |
315 | +{ | 221 | +{ |
316 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 222 | + return extract32(s->otyper, pin, 1) == 1; |
317 | + uint32_t val = val64; | 223 | +} |
318 | + | 224 | + |
319 | + s->regs[R_IR_MASK] |= val; | 225 | +static bool is_push_pull(Stm32l4x5GpioState *s, unsigned pin) |
320 | + crl_update_irq(s); | 226 | +{ |
321 | + return 0; | 227 | + return extract32(s->otyper, pin, 1) == 0; |
322 | +} | 228 | +} |
323 | + | 229 | + |
324 | +static void crl_reset_dev(XlnxVersalCRL *s, DeviceState *dev, | 230 | +static void stm32l4x5_gpio_reset_hold(Object *obj) |
325 | + bool rst_old, bool rst_new) | 231 | +{ |
326 | +{ | 232 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); |
327 | + device_cold_reset(dev); | 233 | + |
328 | +} | 234 | + s->moder = s->moder_reset; |
329 | + | 235 | + s->otyper = 0x00000000; |
330 | +static void crl_reset_cpu(XlnxVersalCRL *s, ARMCPU *armcpu, | 236 | + s->ospeedr = s->ospeedr_reset; |
331 | + bool rst_old, bool rst_new) | 237 | + s->pupdr = s->pupdr_reset; |
332 | +{ | 238 | + s->idr = 0x00000000; |
333 | + if (rst_new) { | 239 | + s->odr = 0x00000000; |
334 | + arm_set_cpu_off(armcpu->mp_affinity); | 240 | + s->lckr = 0x00000000; |
241 | + s->afrl = 0x00000000; | ||
242 | + s->afrh = 0x00000000; | ||
243 | + s->ascr = 0x00000000; | ||
244 | + | ||
245 | + s->disconnected_pins = 0xFFFF; | ||
246 | + s->pins_connected_high = 0x0000; | ||
247 | + update_gpio_idr(s); | ||
248 | +} | ||
249 | + | ||
250 | +static void stm32l4x5_gpio_set(void *opaque, int line, int level) | ||
251 | +{ | ||
252 | + Stm32l4x5GpioState *s = opaque; | ||
253 | + /* | ||
254 | + * The pin isn't set if line is configured in output mode | ||
255 | + * except if level is 0 and the output is open-drain. | ||
256 | + * This way there will be no short-circuit prone situations. | ||
257 | + */ | ||
258 | + if (is_output(s, line) && !(is_open_drain(s, line) && (level == 0))) { | ||
259 | + qemu_log_mask(LOG_GUEST_ERROR, "Line %d can't be driven externally\n", | ||
260 | + line); | ||
261 | + return; | ||
262 | + } | ||
263 | + | ||
264 | + s->disconnected_pins &= ~(1 << line); | ||
265 | + if (level) { | ||
266 | + s->pins_connected_high |= (1 << line); | ||
335 | + } else { | 267 | + } else { |
336 | + arm_set_cpu_on_and_reset(armcpu->mp_affinity); | 268 | + s->pins_connected_high &= ~(1 << line); |
337 | + } | 269 | + } |
338 | +} | 270 | + trace_stm32l4x5_gpio_pins(s->name, s->disconnected_pins, |
339 | + | 271 | + s->pins_connected_high); |
340 | +#define REGFIELD_RESET(type, s, reg, f, new_val, dev) { \ | 272 | + update_gpio_idr(s); |
341 | + bool old_f = ARRAY_FIELD_EX32((s)->regs, reg, f); \ | 273 | +} |
342 | + bool new_f = FIELD_EX32(new_val, reg, f); \ | 274 | + |
343 | + \ | 275 | + |
344 | + /* Detect edges. */ \ | 276 | +static void update_gpio_idr(Stm32l4x5GpioState *s) |
345 | + if (dev && old_f != new_f) { \ | 277 | +{ |
346 | + crl_reset_ ## type(s, dev, old_f, new_f); \ | 278 | + uint32_t new_idr_mask = 0; |
347 | + } \ | 279 | + uint32_t new_idr = s->odr; |
348 | +} | 280 | + uint32_t old_idr = s->idr; |
349 | + | 281 | + int new_pin_state, old_pin_state; |
350 | +static uint64_t crl_rst_r5_prew(RegisterInfo *reg, uint64_t val64) | 282 | + |
351 | +{ | 283 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { |
352 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 284 | + if (is_output(s, i)) { |
353 | + | 285 | + if (is_push_pull(s, i)) { |
354 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU0, val64, s->cfg.cpu_r5[0]); | 286 | + new_idr_mask |= (1 << i); |
355 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU1, val64, s->cfg.cpu_r5[1]); | 287 | + } else if (!(s->odr & (1 << i))) { |
356 | + return val64; | 288 | + /* open-drain ODR 0 */ |
357 | +} | 289 | + new_idr_mask |= (1 << i); |
358 | + | 290 | + /* open-drain ODR 1 */ |
359 | +static uint64_t crl_rst_adma_prew(RegisterInfo *reg, uint64_t val64) | 291 | + } else if (!(s->disconnected_pins & (1 << i)) && |
360 | +{ | 292 | + !(s->pins_connected_high & (1 << i))) { |
361 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 293 | + /* open-drain ODR 1 with pin connected low */ |
362 | + int i; | 294 | + new_idr_mask |= (1 << i); |
363 | + | 295 | + new_idr &= ~(1 << i); |
364 | + /* A single register fans out to all ADMA reset inputs. */ | 296 | + /* open-drain ODR 1 with unactive pin */ |
365 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); i++) { | 297 | + } else if (is_pull_up(s, i)) { |
366 | + REGFIELD_RESET(dev, s, RST_ADMA, RESET, val64, s->cfg.adma[i]); | 298 | + new_idr_mask |= (1 << i); |
367 | + } | 299 | + } else if (is_pull_down(s, i)) { |
368 | + return val64; | 300 | + new_idr_mask |= (1 << i); |
369 | +} | 301 | + new_idr &= ~(1 << i); |
370 | + | 302 | + } |
371 | +static uint64_t crl_rst_uart0_prew(RegisterInfo *reg, uint64_t val64) | 303 | + /* |
372 | +{ | 304 | + * The only case left is for open-drain ODR 1 |
373 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 305 | + * with unactive pin without pull-up or pull-down : |
374 | + | 306 | + * the value is floating. |
375 | + REGFIELD_RESET(dev, s, RST_UART0, RESET, val64, s->cfg.uart[0]); | 307 | + */ |
376 | + return val64; | 308 | + /* input or analog mode with connected pin */ |
377 | +} | 309 | + } else if (!(s->disconnected_pins & (1 << i))) { |
378 | + | 310 | + if (s->pins_connected_high & (1 << i)) { |
379 | +static uint64_t crl_rst_uart1_prew(RegisterInfo *reg, uint64_t val64) | 311 | + /* pin high */ |
380 | +{ | 312 | + new_idr_mask |= (1 << i); |
381 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 313 | + new_idr |= (1 << i); |
382 | + | 314 | + } else { |
383 | + REGFIELD_RESET(dev, s, RST_UART1, RESET, val64, s->cfg.uart[1]); | 315 | + /* pin low */ |
384 | + return val64; | 316 | + new_idr_mask |= (1 << i); |
385 | +} | 317 | + new_idr &= ~(1 << i); |
386 | + | 318 | + } |
387 | +static uint64_t crl_rst_gem0_prew(RegisterInfo *reg, uint64_t val64) | 319 | + /* input or analog mode with disconnected pin */ |
388 | +{ | 320 | + } else { |
389 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 321 | + if (is_pull_up(s, i)) { |
390 | + | 322 | + /* pull-up */ |
391 | + REGFIELD_RESET(dev, s, RST_GEM0, RESET, val64, s->cfg.gem[0]); | 323 | + new_idr_mask |= (1 << i); |
392 | + return val64; | 324 | + new_idr |= (1 << i); |
393 | +} | 325 | + } else if (is_pull_down(s, i)) { |
394 | + | 326 | + /* pull-down */ |
395 | +static uint64_t crl_rst_gem1_prew(RegisterInfo *reg, uint64_t val64) | 327 | + new_idr_mask |= (1 << i); |
396 | +{ | 328 | + new_idr &= ~(1 << i); |
397 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 329 | + } |
398 | + | 330 | + /* |
399 | + REGFIELD_RESET(dev, s, RST_GEM1, RESET, val64, s->cfg.gem[1]); | 331 | + * The only case left is for a disconnected pin |
400 | + return val64; | 332 | + * without pull-up or pull-down : |
401 | +} | 333 | + * the value is floating. |
402 | + | 334 | + */ |
403 | +static uint64_t crl_rst_usb_prew(RegisterInfo *reg, uint64_t val64) | 335 | + } |
404 | +{ | 336 | + } |
405 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | 337 | + |
406 | + | 338 | + s->idr = (old_idr & ~new_idr_mask) | (new_idr & new_idr_mask); |
407 | + REGFIELD_RESET(dev, s, RST_USB0, RESET, val64, s->cfg.usb); | 339 | + trace_stm32l4x5_gpio_update_idr(s->name, old_idr, s->idr); |
408 | + return val64; | 340 | + |
409 | +} | 341 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { |
410 | + | 342 | + if (new_idr_mask & (1 << i)) { |
411 | +static const RegisterAccessInfo crl_regs_info[] = { | 343 | + new_pin_state = (new_idr & (1 << i)) > 0; |
412 | + { .name = "ERR_CTRL", .addr = A_ERR_CTRL, | 344 | + old_pin_state = (old_idr & (1 << i)) > 0; |
413 | + },{ .name = "IR_STATUS", .addr = A_IR_STATUS, | 345 | + if (new_pin_state > old_pin_state) { |
414 | + .w1c = 0x1, | 346 | + qemu_irq_raise(s->pin[i]); |
415 | + .post_write = crl_status_postw, | 347 | + } else if (new_pin_state < old_pin_state) { |
416 | + },{ .name = "IR_MASK", .addr = A_IR_MASK, | 348 | + qemu_irq_lower(s->pin[i]); |
417 | + .reset = 0x1, | 349 | + } |
418 | + .ro = 0x1, | 350 | + } |
419 | + },{ .name = "IR_ENABLE", .addr = A_IR_ENABLE, | 351 | + } |
420 | + .pre_write = crl_enable_prew, | 352 | +} |
421 | + },{ .name = "IR_DISABLE", .addr = A_IR_DISABLE, | 353 | + |
422 | + .pre_write = crl_disable_prew, | 354 | +/* |
423 | + },{ .name = "WPROT", .addr = A_WPROT, | 355 | + * Return mask of pins that are both configured in output |
424 | + },{ .name = "PLL_CLK_OTHER_DMN", .addr = A_PLL_CLK_OTHER_DMN, | 356 | + * mode and externally driven (except pins in open-drain |
425 | + .reset = 0x1, | 357 | + * mode externally set to 0). |
426 | + .rsvd = 0xe, | 358 | + */ |
427 | + },{ .name = "RPLL_CTRL", .addr = A_RPLL_CTRL, | 359 | +static uint32_t get_gpio_pinmask_to_disconnect(Stm32l4x5GpioState *s) |
428 | + .reset = 0x24809, | 360 | +{ |
429 | + .rsvd = 0xf88c00f6, | 361 | + uint32_t pins_to_disconnect = 0; |
430 | + },{ .name = "RPLL_CFG", .addr = A_RPLL_CFG, | 362 | + for (int i = 0; i < GPIO_NUM_PINS; i++) { |
431 | + .reset = 0x2000000, | 363 | + /* for each connected pin in output mode */ |
432 | + .rsvd = 0x1801210, | 364 | + if (!(s->disconnected_pins & (1 << i)) && is_output(s, i)) { |
433 | + },{ .name = "RPLL_FRAC_CFG", .addr = A_RPLL_FRAC_CFG, | 365 | + /* if either push-pull or high level */ |
434 | + .rsvd = 0x7e330000, | 366 | + if (is_push_pull(s, i) || s->pins_connected_high & (1 << i)) { |
435 | + },{ .name = "PLL_STATUS", .addr = A_PLL_STATUS, | 367 | + pins_to_disconnect |= (1 << i); |
436 | + .reset = R_PLL_STATUS_RPLL_STABLE_MASK | | 368 | + qemu_log_mask(LOG_GUEST_ERROR, |
437 | + R_PLL_STATUS_RPLL_LOCK_MASK, | 369 | + "Line %d can't be driven externally\n", |
438 | + .rsvd = 0xfa, | 370 | + i); |
439 | + .ro = 0x5, | 371 | + } |
440 | + },{ .name = "RPLL_TO_XPD_CTRL", .addr = A_RPLL_TO_XPD_CTRL, | 372 | + } |
441 | + .reset = 0x2000100, | 373 | + } |
442 | + .rsvd = 0xfdfc00ff, | 374 | + return pins_to_disconnect; |
443 | + },{ .name = "LPD_TOP_SWITCH_CTRL", .addr = A_LPD_TOP_SWITCH_CTRL, | 375 | +} |
444 | + .reset = 0x6000300, | 376 | + |
445 | + .rsvd = 0xf9fc00f8, | 377 | +/* |
446 | + },{ .name = "LPD_LSBUS_CTRL", .addr = A_LPD_LSBUS_CTRL, | 378 | + * Set field `disconnected_pins` and call `update_gpio_idr()` |
447 | + .reset = 0x2000800, | 379 | + */ |
448 | + .rsvd = 0xfdfc00f8, | 380 | +static void disconnect_gpio_pins(Stm32l4x5GpioState *s, uint16_t lines) |
449 | + },{ .name = "CPU_R5_CTRL", .addr = A_CPU_R5_CTRL, | 381 | +{ |
450 | + .reset = 0xe000300, | 382 | + s->disconnected_pins |= lines; |
451 | + .rsvd = 0xe1fc00f8, | 383 | + trace_stm32l4x5_gpio_pins(s->name, s->disconnected_pins, |
452 | + },{ .name = "IOU_SWITCH_CTRL", .addr = A_IOU_SWITCH_CTRL, | 384 | + s->pins_connected_high); |
453 | + .reset = 0x2000500, | 385 | + update_gpio_idr(s); |
454 | + .rsvd = 0xfdfc00f8, | 386 | +} |
455 | + },{ .name = "GEM0_REF_CTRL", .addr = A_GEM0_REF_CTRL, | 387 | + |
456 | + .reset = 0xe000a00, | 388 | +static void disconnected_pins_set(Object *obj, Visitor *v, |
457 | + .rsvd = 0xf1fc00f8, | 389 | + const char *name, void *opaque, Error **errp) |
458 | + },{ .name = "GEM1_REF_CTRL", .addr = A_GEM1_REF_CTRL, | 390 | +{ |
459 | + .reset = 0xe000a00, | 391 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); |
460 | + .rsvd = 0xf1fc00f8, | 392 | + uint16_t value; |
461 | + },{ .name = "GEM_TSU_REF_CTRL", .addr = A_GEM_TSU_REF_CTRL, | 393 | + if (!visit_type_uint16(v, name, &value, errp)) { |
462 | + .reset = 0x300, | 394 | + return; |
463 | + .rsvd = 0xfdfc00f8, | 395 | + } |
464 | + },{ .name = "USB0_BUS_REF_CTRL", .addr = A_USB0_BUS_REF_CTRL, | 396 | + disconnect_gpio_pins(s, value); |
465 | + .reset = 0x2001900, | 397 | +} |
466 | + .rsvd = 0xfdfc00f8, | 398 | + |
467 | + },{ .name = "UART0_REF_CTRL", .addr = A_UART0_REF_CTRL, | 399 | +static void disconnected_pins_get(Object *obj, Visitor *v, |
468 | + .reset = 0xc00, | 400 | + const char *name, void *opaque, Error **errp) |
469 | + .rsvd = 0xfdfc00f8, | 401 | +{ |
470 | + },{ .name = "UART1_REF_CTRL", .addr = A_UART1_REF_CTRL, | 402 | + visit_type_uint16(v, name, (uint16_t *)opaque, errp); |
471 | + .reset = 0xc00, | 403 | +} |
472 | + .rsvd = 0xfdfc00f8, | 404 | + |
473 | + },{ .name = "SPI0_REF_CTRL", .addr = A_SPI0_REF_CTRL, | 405 | +static void clock_freq_get(Object *obj, Visitor *v, |
474 | + .reset = 0x600, | 406 | + const char *name, void *opaque, Error **errp) |
475 | + .rsvd = 0xfdfc00f8, | 407 | +{ |
476 | + },{ .name = "SPI1_REF_CTRL", .addr = A_SPI1_REF_CTRL, | 408 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); |
477 | + .reset = 0x600, | 409 | + uint32_t clock_freq_hz = clock_get_hz(s->clk); |
478 | + .rsvd = 0xfdfc00f8, | 410 | + visit_type_uint32(v, name, &clock_freq_hz, errp); |
479 | + },{ .name = "CAN0_REF_CTRL", .addr = A_CAN0_REF_CTRL, | 411 | +} |
480 | + .reset = 0xc00, | 412 | + |
481 | + .rsvd = 0xfdfc00f8, | 413 | +static void stm32l4x5_gpio_write(void *opaque, hwaddr addr, |
482 | + },{ .name = "CAN1_REF_CTRL", .addr = A_CAN1_REF_CTRL, | 414 | + uint64_t val64, unsigned int size) |
483 | + .reset = 0xc00, | 415 | +{ |
484 | + .rsvd = 0xfdfc00f8, | 416 | + Stm32l4x5GpioState *s = opaque; |
485 | + },{ .name = "I2C0_REF_CTRL", .addr = A_I2C0_REF_CTRL, | 417 | + |
486 | + .reset = 0xc00, | 418 | + uint32_t value = val64; |
487 | + .rsvd = 0xfdfc00f8, | 419 | + trace_stm32l4x5_gpio_write(s->name, addr, val64); |
488 | + },{ .name = "I2C1_REF_CTRL", .addr = A_I2C1_REF_CTRL, | 420 | + |
489 | + .reset = 0xc00, | 421 | + switch (addr) { |
490 | + .rsvd = 0xfdfc00f8, | 422 | + case GPIO_MODER: |
491 | + },{ .name = "DBG_LPD_CTRL", .addr = A_DBG_LPD_CTRL, | 423 | + s->moder = value; |
492 | + .reset = 0x300, | 424 | + disconnect_gpio_pins(s, get_gpio_pinmask_to_disconnect(s)); |
493 | + .rsvd = 0xfdfc00f8, | 425 | + qemu_log_mask(LOG_UNIMP, |
494 | + },{ .name = "TIMESTAMP_REF_CTRL", .addr = A_TIMESTAMP_REF_CTRL, | 426 | + "%s: Analog and AF modes aren't supported\n\ |
495 | + .reset = 0x2000c00, | 427 | + Analog and AF mode behave like input mode\n", |
496 | + .rsvd = 0xfdfc00f8, | 428 | + __func__); |
497 | + },{ .name = "CRL_SAFETY_CHK", .addr = A_CRL_SAFETY_CHK, | 429 | + return; |
498 | + },{ .name = "PSM_REF_CTRL", .addr = A_PSM_REF_CTRL, | 430 | + case GPIO_OTYPER: |
499 | + .reset = 0xf04, | 431 | + s->otyper = value & ~RESERVED_BITS_MASK; |
500 | + .rsvd = 0xfffc00f8, | 432 | + disconnect_gpio_pins(s, get_gpio_pinmask_to_disconnect(s)); |
501 | + },{ .name = "DBG_TSTMP_CTRL", .addr = A_DBG_TSTMP_CTRL, | 433 | + return; |
502 | + .reset = 0x300, | 434 | + case GPIO_OSPEEDR: |
503 | + .rsvd = 0xfdfc00f8, | 435 | + qemu_log_mask(LOG_UNIMP, |
504 | + },{ .name = "CPM_TOPSW_REF_CTRL", .addr = A_CPM_TOPSW_REF_CTRL, | 436 | + "%s: Changing I/O output speed isn't supported\n\ |
505 | + .reset = 0x300, | 437 | + I/O speed is already maximal\n", |
506 | + .rsvd = 0xfdfc00f8, | 438 | + __func__); |
507 | + },{ .name = "USB3_DUAL_REF_CTRL", .addr = A_USB3_DUAL_REF_CTRL, | 439 | + s->ospeedr = value; |
508 | + .reset = 0x3c00, | 440 | + return; |
509 | + .rsvd = 0xfdfc00f8, | 441 | + case GPIO_PUPDR: |
510 | + },{ .name = "RST_CPU_R5", .addr = A_RST_CPU_R5, | 442 | + s->pupdr = value; |
511 | + .reset = 0x17, | 443 | + update_gpio_idr(s); |
512 | + .rsvd = 0x8, | 444 | + return; |
513 | + .pre_write = crl_rst_r5_prew, | 445 | + case GPIO_IDR: |
514 | + },{ .name = "RST_ADMA", .addr = A_RST_ADMA, | 446 | + qemu_log_mask(LOG_UNIMP, |
515 | + .reset = 0x1, | 447 | + "%s: GPIO->IDR is read-only\n", |
516 | + .pre_write = crl_rst_adma_prew, | 448 | + __func__); |
517 | + },{ .name = "RST_GEM0", .addr = A_RST_GEM0, | 449 | + return; |
518 | + .reset = 0x1, | 450 | + case GPIO_ODR: |
519 | + .pre_write = crl_rst_gem0_prew, | 451 | + s->odr = value & ~RESERVED_BITS_MASK; |
520 | + },{ .name = "RST_GEM1", .addr = A_RST_GEM1, | 452 | + update_gpio_idr(s); |
521 | + .reset = 0x1, | 453 | + return; |
522 | + .pre_write = crl_rst_gem1_prew, | 454 | + case GPIO_BSRR: { |
523 | + },{ .name = "RST_SPARE", .addr = A_RST_SPARE, | 455 | + uint32_t bits_to_reset = (value & RESERVED_BITS_MASK) >> GPIO_NUM_PINS; |
524 | + .reset = 0x1, | 456 | + uint32_t bits_to_set = value & ~RESERVED_BITS_MASK; |
525 | + },{ .name = "RST_USB0", .addr = A_RST_USB0, | 457 | + /* If both BSx and BRx are set, BSx has priority.*/ |
526 | + .reset = 0x1, | 458 | + s->odr &= ~bits_to_reset; |
527 | + .pre_write = crl_rst_usb_prew, | 459 | + s->odr |= bits_to_set; |
528 | + },{ .name = "RST_UART0", .addr = A_RST_UART0, | 460 | + update_gpio_idr(s); |
529 | + .reset = 0x1, | 461 | + return; |
530 | + .pre_write = crl_rst_uart0_prew, | 462 | + } |
531 | + },{ .name = "RST_UART1", .addr = A_RST_UART1, | 463 | + case GPIO_LCKR: |
532 | + .reset = 0x1, | 464 | + qemu_log_mask(LOG_UNIMP, |
533 | + .pre_write = crl_rst_uart1_prew, | 465 | + "%s: Locking port bits configuration isn't supported\n", |
534 | + },{ .name = "RST_SPI0", .addr = A_RST_SPI0, | 466 | + __func__); |
535 | + .reset = 0x1, | 467 | + s->lckr = value & ~RESERVED_BITS_MASK; |
536 | + },{ .name = "RST_SPI1", .addr = A_RST_SPI1, | 468 | + return; |
537 | + .reset = 0x1, | 469 | + case GPIO_AFRL: |
538 | + },{ .name = "RST_CAN0", .addr = A_RST_CAN0, | 470 | + qemu_log_mask(LOG_UNIMP, |
539 | + .reset = 0x1, | 471 | + "%s: Alternate functions aren't supported\n", |
540 | + },{ .name = "RST_CAN1", .addr = A_RST_CAN1, | 472 | + __func__); |
541 | + .reset = 0x1, | 473 | + s->afrl = value; |
542 | + },{ .name = "RST_I2C0", .addr = A_RST_I2C0, | 474 | + return; |
543 | + .reset = 0x1, | 475 | + case GPIO_AFRH: |
544 | + },{ .name = "RST_I2C1", .addr = A_RST_I2C1, | 476 | + qemu_log_mask(LOG_UNIMP, |
545 | + .reset = 0x1, | 477 | + "%s: Alternate functions aren't supported\n", |
546 | + },{ .name = "RST_DBG_LPD", .addr = A_RST_DBG_LPD, | 478 | + __func__); |
547 | + .reset = 0x33, | 479 | + s->afrh = value; |
548 | + .rsvd = 0xcc, | 480 | + return; |
549 | + },{ .name = "RST_GPIO", .addr = A_RST_GPIO, | 481 | + case GPIO_BRR: { |
550 | + .reset = 0x1, | 482 | + uint32_t bits_to_reset = value & ~RESERVED_BITS_MASK; |
551 | + },{ .name = "RST_TTC", .addr = A_RST_TTC, | 483 | + s->odr &= ~bits_to_reset; |
552 | + .reset = 0xf, | 484 | + update_gpio_idr(s); |
553 | + },{ .name = "RST_TIMESTAMP", .addr = A_RST_TIMESTAMP, | 485 | + return; |
554 | + .reset = 0x1, | 486 | + } |
555 | + },{ .name = "RST_SWDT", .addr = A_RST_SWDT, | 487 | + case GPIO_ASCR: |
556 | + .reset = 0x1, | 488 | + qemu_log_mask(LOG_UNIMP, |
557 | + },{ .name = "RST_OCM", .addr = A_RST_OCM, | 489 | + "%s: ADC function isn't supported\n", |
558 | + },{ .name = "RST_IPI", .addr = A_RST_IPI, | 490 | + __func__); |
559 | + },{ .name = "RST_FPD", .addr = A_RST_FPD, | 491 | + s->ascr = value & ~RESERVED_BITS_MASK; |
560 | + .reset = 0x3, | 492 | + return; |
561 | + },{ .name = "PSM_RST_MODE", .addr = A_PSM_RST_MODE, | 493 | + default: |
562 | + .reset = 0x1, | 494 | + qemu_log_mask(LOG_GUEST_ERROR, |
563 | + .rsvd = 0xf8, | 495 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, addr); |
564 | + } | 496 | + } |
565 | +}; | 497 | +} |
566 | + | 498 | + |
567 | +static void crl_reset_enter(Object *obj, ResetType type) | 499 | +static uint64_t stm32l4x5_gpio_read(void *opaque, hwaddr addr, |
568 | +{ | 500 | + unsigned int size) |
569 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | 501 | +{ |
570 | + unsigned int i; | 502 | + Stm32l4x5GpioState *s = opaque; |
571 | + | 503 | + |
572 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | 504 | + trace_stm32l4x5_gpio_read(s->name, addr); |
573 | + register_reset(&s->regs_info[i]); | 505 | + |
574 | + } | 506 | + switch (addr) { |
575 | +} | 507 | + case GPIO_MODER: |
576 | + | 508 | + return s->moder; |
577 | +static void crl_reset_hold(Object *obj) | 509 | + case GPIO_OTYPER: |
578 | +{ | 510 | + return s->otyper; |
579 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | 511 | + case GPIO_OSPEEDR: |
580 | + | 512 | + return s->ospeedr; |
581 | + crl_update_irq(s); | 513 | + case GPIO_PUPDR: |
582 | +} | 514 | + return s->pupdr; |
583 | + | 515 | + case GPIO_IDR: |
584 | +static const MemoryRegionOps crl_ops = { | 516 | + return s->idr; |
585 | + .read = register_read_memory, | 517 | + case GPIO_ODR: |
586 | + .write = register_write_memory, | 518 | + return s->odr; |
587 | + .endianness = DEVICE_LITTLE_ENDIAN, | 519 | + case GPIO_BSRR: |
520 | + return 0; | ||
521 | + case GPIO_LCKR: | ||
522 | + return s->lckr; | ||
523 | + case GPIO_AFRL: | ||
524 | + return s->afrl; | ||
525 | + case GPIO_AFRH: | ||
526 | + return s->afrh; | ||
527 | + case GPIO_BRR: | ||
528 | + return 0; | ||
529 | + case GPIO_ASCR: | ||
530 | + return s->ascr; | ||
531 | + default: | ||
532 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
533 | + "%s: Bad offset 0x%" HWADDR_PRIx "\n", __func__, addr); | ||
534 | + return 0; | ||
535 | + } | ||
536 | +} | ||
537 | + | ||
538 | +static const MemoryRegionOps stm32l4x5_gpio_ops = { | ||
539 | + .read = stm32l4x5_gpio_read, | ||
540 | + .write = stm32l4x5_gpio_write, | ||
541 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
542 | + .impl = { | ||
543 | + .min_access_size = 4, | ||
544 | + .max_access_size = 4, | ||
545 | + .unaligned = false, | ||
546 | + }, | ||
588 | + .valid = { | 547 | + .valid = { |
589 | + .min_access_size = 4, | 548 | + .min_access_size = 4, |
590 | + .max_access_size = 4, | 549 | + .max_access_size = 4, |
550 | + .unaligned = false, | ||
591 | + }, | 551 | + }, |
592 | +}; | 552 | +}; |
593 | + | 553 | + |
594 | +static void crl_init(Object *obj) | 554 | +static void stm32l4x5_gpio_init(Object *obj) |
595 | +{ | 555 | +{ |
596 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | 556 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(obj); |
597 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | 557 | + |
598 | + int i; | 558 | + memory_region_init_io(&s->mmio, obj, &stm32l4x5_gpio_ops, s, |
599 | + | 559 | + TYPE_STM32L4X5_GPIO, 0x400); |
600 | + s->reg_array = | 560 | + |
601 | + register_init_block32(DEVICE(obj), crl_regs_info, | 561 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); |
602 | + ARRAY_SIZE(crl_regs_info), | 562 | + |
603 | + s->regs_info, s->regs, | 563 | + qdev_init_gpio_out(DEVICE(obj), s->pin, GPIO_NUM_PINS); |
604 | + &crl_ops, | 564 | + qdev_init_gpio_in(DEVICE(obj), stm32l4x5_gpio_set, GPIO_NUM_PINS); |
605 | + XLNX_VERSAL_CRL_ERR_DEBUG, | 565 | + |
606 | + CRL_R_MAX * 4); | 566 | + s->clk = qdev_init_clock_in(DEVICE(s), "clk", NULL, s, 0); |
607 | + sysbus_init_mmio(sbd, &s->reg_array->mem); | 567 | + |
608 | + sysbus_init_irq(sbd, &s->irq); | 568 | + object_property_add(obj, "disconnected-pins", "uint16", |
609 | + | 569 | + disconnected_pins_get, disconnected_pins_set, |
610 | + for (i = 0; i < ARRAY_SIZE(s->cfg.cpu_r5); ++i) { | 570 | + NULL, &s->disconnected_pins); |
611 | + object_property_add_link(obj, "cpu_r5[*]", TYPE_ARM_CPU, | 571 | + object_property_add(obj, "clock-freq-hz", "uint32", |
612 | + (Object **)&s->cfg.cpu_r5[i], | 572 | + clock_freq_get, NULL, NULL, NULL); |
613 | + qdev_prop_allow_set_link_before_realize, | 573 | +} |
614 | + OBJ_PROP_LINK_STRONG); | 574 | + |
615 | + } | 575 | +static void stm32l4x5_gpio_realize(DeviceState *dev, Error **errp) |
616 | + | 576 | +{ |
617 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); ++i) { | 577 | + Stm32l4x5GpioState *s = STM32L4X5_GPIO(dev); |
618 | + object_property_add_link(obj, "adma[*]", TYPE_DEVICE, | 578 | + if (!clock_has_source(s->clk)) { |
619 | + (Object **)&s->cfg.adma[i], | 579 | + error_setg(errp, "GPIO: clk input must be connected"); |
620 | + qdev_prop_allow_set_link_before_realize, | 580 | + return; |
621 | + OBJ_PROP_LINK_STRONG); | 581 | + } |
622 | + } | 582 | +} |
623 | + | 583 | + |
624 | + for (i = 0; i < ARRAY_SIZE(s->cfg.uart); ++i) { | 584 | +static const VMStateDescription vmstate_stm32l4x5_gpio = { |
625 | + object_property_add_link(obj, "uart[*]", TYPE_DEVICE, | 585 | + .name = TYPE_STM32L4X5_GPIO, |
626 | + (Object **)&s->cfg.uart[i], | ||
627 | + qdev_prop_allow_set_link_before_realize, | ||
628 | + OBJ_PROP_LINK_STRONG); | ||
629 | + } | ||
630 | + | ||
631 | + for (i = 0; i < ARRAY_SIZE(s->cfg.gem); ++i) { | ||
632 | + object_property_add_link(obj, "gem[*]", TYPE_DEVICE, | ||
633 | + (Object **)&s->cfg.gem[i], | ||
634 | + qdev_prop_allow_set_link_before_realize, | ||
635 | + OBJ_PROP_LINK_STRONG); | ||
636 | + } | ||
637 | + | ||
638 | + object_property_add_link(obj, "usb", TYPE_DEVICE, | ||
639 | + (Object **)&s->cfg.gem[i], | ||
640 | + qdev_prop_allow_set_link_before_realize, | ||
641 | + OBJ_PROP_LINK_STRONG); | ||
642 | +} | ||
643 | + | ||
644 | +static void crl_finalize(Object *obj) | ||
645 | +{ | ||
646 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
647 | + register_finalize_block(s->reg_array); | ||
648 | +} | ||
649 | + | ||
650 | +static const VMStateDescription vmstate_crl = { | ||
651 | + .name = TYPE_XLNX_VERSAL_CRL, | ||
652 | + .version_id = 1, | 586 | + .version_id = 1, |
653 | + .minimum_version_id = 1, | 587 | + .minimum_version_id = 1, |
654 | + .fields = (VMStateField[]) { | 588 | + .fields = (VMStateField[]){ |
655 | + VMSTATE_UINT32_ARRAY(regs, XlnxVersalCRL, CRL_R_MAX), | 589 | + VMSTATE_UINT32(moder, Stm32l4x5GpioState), |
656 | + VMSTATE_END_OF_LIST(), | 590 | + VMSTATE_UINT32(otyper, Stm32l4x5GpioState), |
591 | + VMSTATE_UINT32(ospeedr, Stm32l4x5GpioState), | ||
592 | + VMSTATE_UINT32(pupdr, Stm32l4x5GpioState), | ||
593 | + VMSTATE_UINT32(idr, Stm32l4x5GpioState), | ||
594 | + VMSTATE_UINT32(odr, Stm32l4x5GpioState), | ||
595 | + VMSTATE_UINT32(lckr, Stm32l4x5GpioState), | ||
596 | + VMSTATE_UINT32(afrl, Stm32l4x5GpioState), | ||
597 | + VMSTATE_UINT32(afrh, Stm32l4x5GpioState), | ||
598 | + VMSTATE_UINT32(ascr, Stm32l4x5GpioState), | ||
599 | + VMSTATE_UINT16(disconnected_pins, Stm32l4x5GpioState), | ||
600 | + VMSTATE_UINT16(pins_connected_high, Stm32l4x5GpioState), | ||
601 | + VMSTATE_END_OF_LIST() | ||
657 | + } | 602 | + } |
658 | +}; | 603 | +}; |
659 | + | 604 | + |
660 | +static void crl_class_init(ObjectClass *klass, void *data) | 605 | +static Property stm32l4x5_gpio_properties[] = { |
661 | +{ | 606 | + DEFINE_PROP_STRING("name", Stm32l4x5GpioState, name), |
607 | + DEFINE_PROP_UINT32("mode-reset", Stm32l4x5GpioState, moder_reset, 0), | ||
608 | + DEFINE_PROP_UINT32("ospeed-reset", Stm32l4x5GpioState, ospeedr_reset, 0), | ||
609 | + DEFINE_PROP_UINT32("pupd-reset", Stm32l4x5GpioState, pupdr_reset, 0), | ||
610 | + DEFINE_PROP_END_OF_LIST(), | ||
611 | +}; | ||
612 | + | ||
613 | +static void stm32l4x5_gpio_class_init(ObjectClass *klass, void *data) | ||
614 | +{ | ||
615 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
662 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | 616 | + ResettableClass *rc = RESETTABLE_CLASS(klass); |
663 | + DeviceClass *dc = DEVICE_CLASS(klass); | 617 | + |
664 | + | 618 | + device_class_set_props(dc, stm32l4x5_gpio_properties); |
665 | + dc->vmsd = &vmstate_crl; | 619 | + dc->vmsd = &vmstate_stm32l4x5_gpio; |
666 | + | 620 | + dc->realize = stm32l4x5_gpio_realize; |
667 | + rc->phases.enter = crl_reset_enter; | 621 | + rc->phases.hold = stm32l4x5_gpio_reset_hold; |
668 | + rc->phases.hold = crl_reset_hold; | 622 | +} |
669 | +} | 623 | + |
670 | + | 624 | +static const TypeInfo stm32l4x5_gpio_types[] = { |
671 | +static const TypeInfo crl_info = { | 625 | + { |
672 | + .name = TYPE_XLNX_VERSAL_CRL, | 626 | + .name = TYPE_STM32L4X5_GPIO, |
673 | + .parent = TYPE_SYS_BUS_DEVICE, | 627 | + .parent = TYPE_SYS_BUS_DEVICE, |
674 | + .instance_size = sizeof(XlnxVersalCRL), | 628 | + .instance_size = sizeof(Stm32l4x5GpioState), |
675 | + .class_init = crl_class_init, | 629 | + .instance_init = stm32l4x5_gpio_init, |
676 | + .instance_init = crl_init, | 630 | + .class_init = stm32l4x5_gpio_class_init, |
677 | + .instance_finalize = crl_finalize, | 631 | + }, |
678 | +}; | 632 | +}; |
679 | + | 633 | + |
680 | +static void crl_register_types(void) | 634 | +DEFINE_TYPES(stm32l4x5_gpio_types) |
681 | +{ | 635 | diff --git a/hw/gpio/Kconfig b/hw/gpio/Kconfig |
682 | + type_register_static(&crl_info); | ||
683 | +} | ||
684 | + | ||
685 | +type_init(crl_register_types) | ||
686 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build | ||
687 | index XXXXXXX..XXXXXXX 100644 | 636 | index XXXXXXX..XXXXXXX 100644 |
688 | --- a/hw/misc/meson.build | 637 | --- a/hw/gpio/Kconfig |
689 | +++ b/hw/misc/meson.build | 638 | +++ b/hw/gpio/Kconfig |
690 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) | 639 | @@ -XXX,XX +XXX,XX @@ config GPIO_PWR |
691 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c')) | 640 | |
692 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c')) | 641 | config SIFIVE_GPIO |
693 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c')) | 642 | bool |
694 | +specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-crl.c')) | 643 | + |
695 | softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( | 644 | +config STM32L4X5_GPIO |
696 | 'xlnx-versal-xramc.c', | 645 | + bool |
697 | 'xlnx-versal-pmc-iou-slcr.c', | 646 | diff --git a/hw/gpio/meson.build b/hw/gpio/meson.build |
647 | index XXXXXXX..XXXXXXX 100644 | ||
648 | --- a/hw/gpio/meson.build | ||
649 | +++ b/hw/gpio/meson.build | ||
650 | @@ -XXX,XX +XXX,XX @@ system_ss.add(when: 'CONFIG_RASPI', if_true: files( | ||
651 | 'bcm2835_gpio.c', | ||
652 | 'bcm2838_gpio.c' | ||
653 | )) | ||
654 | +system_ss.add(when: 'CONFIG_STM32L4X5_SOC', if_true: files('stm32l4x5_gpio.c')) | ||
655 | system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c')) | ||
656 | system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c')) | ||
657 | diff --git a/hw/gpio/trace-events b/hw/gpio/trace-events | ||
658 | index XXXXXXX..XXXXXXX 100644 | ||
659 | --- a/hw/gpio/trace-events | ||
660 | +++ b/hw/gpio/trace-events | ||
661 | @@ -XXX,XX +XXX,XX @@ sifive_gpio_update_output_irq(int64_t line, int64_t value) "line %" PRIi64 " val | ||
662 | # aspeed_gpio.c | ||
663 | aspeed_gpio_read(uint64_t offset, uint64_t value) "offset: 0x%" PRIx64 " value 0x%" PRIx64 | ||
664 | aspeed_gpio_write(uint64_t offset, uint64_t value) "offset: 0x%" PRIx64 " value 0x%" PRIx64 | ||
665 | + | ||
666 | +# stm32l4x5_gpio.c | ||
667 | +stm32l4x5_gpio_read(char *gpio, uint64_t addr) "GPIO%s addr: 0x%" PRIx64 " " | ||
668 | +stm32l4x5_gpio_write(char *gpio, uint64_t addr, uint64_t data) "GPIO%s addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" | ||
669 | +stm32l4x5_gpio_update_idr(char *gpio, uint32_t old_idr, uint32_t new_idr) "GPIO%s from: 0x%x to: 0x%x" | ||
670 | +stm32l4x5_gpio_pins(char *gpio, uint16_t disconnected, uint16_t high) "GPIO%s disconnected pins: 0x%x levels: 0x%x" | ||
698 | -- | 671 | -- |
699 | 2.25.1 | 672 | 2.34.1 |
673 | |||
674 | diff view generated by jsdifflib |
1 | The Exynos4210 SoC device currently uses a custom device | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | "exynos4210.irq_gate" to model the OR gate that feeds each CPU's IRQ | 2 | |
3 | line. We have a standard TYPE_OR_IRQ device for this now, so use | 3 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> |
4 | that instead. | 4 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> |
5 | 5 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | |
6 | (This is a migration compatibility break, but that is OK for this | 6 | Acked-by: Alistair Francis <alistair.francis@wdc.com> |
7 | machine type.) | 7 | Message-id: 20240305210444.310665-3-ines.varhol@telecom-paris.fr |
8 | |||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-2-peter.maydell@linaro.org | ||
12 | --- | 9 | --- |
13 | include/hw/arm/exynos4210.h | 1 + | 10 | include/hw/arm/stm32l4x5_soc.h | 2 + |
14 | hw/arm/exynos4210.c | 31 ++++++++++++++++--------------- | 11 | include/hw/gpio/stm32l4x5_gpio.h | 1 + |
15 | 2 files changed, 17 insertions(+), 15 deletions(-) | 12 | include/hw/misc/stm32l4x5_syscfg.h | 3 +- |
16 | 13 | hw/arm/stm32l4x5_soc.c | 71 +++++++++++++++++++++++------- | |
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 14 | hw/misc/stm32l4x5_syscfg.c | 1 + |
18 | index XXXXXXX..XXXXXXX 100644 | 15 | hw/arm/Kconfig | 3 +- |
19 | --- a/include/hw/arm/exynos4210.h | 16 | 6 files changed, 63 insertions(+), 18 deletions(-) |
20 | +++ b/include/hw/arm/exynos4210.h | 17 | |
21 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | 18 | diff --git a/include/hw/arm/stm32l4x5_soc.h b/include/hw/arm/stm32l4x5_soc.h |
22 | MemoryRegion bootreg_mem; | 19 | index XXXXXXX..XXXXXXX 100644 |
23 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | 20 | --- a/include/hw/arm/stm32l4x5_soc.h |
24 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | 21 | +++ b/include/hw/arm/stm32l4x5_soc.h |
25 | + qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | 22 | @@ -XXX,XX +XXX,XX @@ |
23 | #include "hw/misc/stm32l4x5_syscfg.h" | ||
24 | #include "hw/misc/stm32l4x5_exti.h" | ||
25 | #include "hw/misc/stm32l4x5_rcc.h" | ||
26 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
27 | #include "qom/object.h" | ||
28 | |||
29 | #define TYPE_STM32L4X5_SOC "stm32l4x5-soc" | ||
30 | @@ -XXX,XX +XXX,XX @@ struct Stm32l4x5SocState { | ||
31 | OrIRQState exti_or_gates[NUM_EXTI_OR_GATES]; | ||
32 | Stm32l4x5SyscfgState syscfg; | ||
33 | Stm32l4x5RccState rcc; | ||
34 | + Stm32l4x5GpioState gpio[NUM_GPIOS]; | ||
35 | |||
36 | MemoryRegion sram1; | ||
37 | MemoryRegion sram2; | ||
38 | diff --git a/include/hw/gpio/stm32l4x5_gpio.h b/include/hw/gpio/stm32l4x5_gpio.h | ||
39 | index XXXXXXX..XXXXXXX 100644 | ||
40 | --- a/include/hw/gpio/stm32l4x5_gpio.h | ||
41 | +++ b/include/hw/gpio/stm32l4x5_gpio.h | ||
42 | @@ -XXX,XX +XXX,XX @@ | ||
43 | #define TYPE_STM32L4X5_GPIO "stm32l4x5-gpio" | ||
44 | OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5GpioState, STM32L4X5_GPIO) | ||
45 | |||
46 | +#define NUM_GPIOS 8 | ||
47 | #define GPIO_NUM_PINS 16 | ||
48 | |||
49 | struct Stm32l4x5GpioState { | ||
50 | diff --git a/include/hw/misc/stm32l4x5_syscfg.h b/include/hw/misc/stm32l4x5_syscfg.h | ||
51 | index XXXXXXX..XXXXXXX 100644 | ||
52 | --- a/include/hw/misc/stm32l4x5_syscfg.h | ||
53 | +++ b/include/hw/misc/stm32l4x5_syscfg.h | ||
54 | @@ -XXX,XX +XXX,XX @@ | ||
55 | |||
56 | #include "hw/sysbus.h" | ||
57 | #include "qom/object.h" | ||
58 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
59 | |||
60 | #define TYPE_STM32L4X5_SYSCFG "stm32l4x5-syscfg" | ||
61 | OBJECT_DECLARE_SIMPLE_TYPE(Stm32l4x5SyscfgState, STM32L4X5_SYSCFG) | ||
62 | |||
63 | -#define NUM_GPIOS 8 | ||
64 | -#define GPIO_NUM_PINS 16 | ||
65 | #define SYSCFG_NUM_EXTICR 4 | ||
66 | |||
67 | struct Stm32l4x5SyscfgState { | ||
68 | diff --git a/hw/arm/stm32l4x5_soc.c b/hw/arm/stm32l4x5_soc.c | ||
69 | index XXXXXXX..XXXXXXX 100644 | ||
70 | --- a/hw/arm/stm32l4x5_soc.c | ||
71 | +++ b/hw/arm/stm32l4x5_soc.c | ||
72 | @@ -XXX,XX +XXX,XX @@ | ||
73 | #include "sysemu/sysemu.h" | ||
74 | #include "hw/or-irq.h" | ||
75 | #include "hw/arm/stm32l4x5_soc.h" | ||
76 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
77 | #include "hw/qdev-clock.h" | ||
78 | #include "hw/misc/unimp.h" | ||
79 | |||
80 | @@ -XXX,XX +XXX,XX @@ static const int exti_or_gate1_lines_in[EXTI_OR_GATE1_NUM_LINES_IN] = { | ||
81 | 16, 35, 36, 37, 38, | ||
26 | }; | 82 | }; |
27 | 83 | ||
28 | #define TYPE_EXYNOS4210_SOC "exynos4210" | 84 | +static const struct { |
29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 85 | + uint32_t addr; |
30 | index XXXXXXX..XXXXXXX 100644 | 86 | + uint32_t moder_reset; |
31 | --- a/hw/arm/exynos4210.c | 87 | + uint32_t ospeedr_reset; |
32 | +++ b/hw/arm/exynos4210.c | 88 | + uint32_t pupdr_reset; |
33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | 89 | +} stm32l4x5_gpio_cfg[NUM_GPIOS] = { |
90 | + { 0x48000000, 0xABFFFFFF, 0x0C000000, 0x64000000 }, | ||
91 | + { 0x48000400, 0xFFFFFEBF, 0x00000000, 0x00000100 }, | ||
92 | + { 0x48000800, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
93 | + { 0x48000C00, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
94 | + { 0x48001000, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
95 | + { 0x48001400, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
96 | + { 0x48001800, 0xFFFFFFFF, 0x00000000, 0x00000000 }, | ||
97 | + { 0x48001C00, 0x0000000F, 0x00000000, 0x00000000 }, | ||
98 | +}; | ||
99 | + | ||
100 | static void stm32l4x5_soc_initfn(Object *obj) | ||
34 | { | 101 | { |
35 | Exynos4210State *s = EXYNOS4210_SOC(socdev); | 102 | Stm32l4x5SocState *s = STM32L4X5_SOC(obj); |
36 | MemoryRegion *system_mem = get_system_memory(); | 103 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_initfn(Object *obj) |
37 | - qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | 104 | } |
38 | SysBusDevice *busdev; | 105 | object_initialize_child(obj, "syscfg", &s->syscfg, TYPE_STM32L4X5_SYSCFG); |
39 | DeviceState *dev, *uart[4], *pl330[3]; | 106 | object_initialize_child(obj, "rcc", &s->rcc, TYPE_STM32L4X5_RCC); |
40 | int i, n; | 107 | + |
41 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | 108 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { |
42 | 109 | + g_autofree char *name = g_strdup_printf("gpio%c", 'a' + i); | |
43 | /* IRQ Gate */ | 110 | + object_initialize_child(obj, name, &s->gpio[i], TYPE_STM32L4X5_GPIO); |
44 | for (i = 0; i < EXYNOS4210_NCPUS; i++) { | ||
45 | - dev = qdev_new("exynos4210.irq_gate"); | ||
46 | - qdev_prop_set_uint32(dev, "n_in", EXYNOS4210_IRQ_GATE_NINPUTS); | ||
47 | - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); | ||
48 | - /* Get IRQ Gate input in gate_irq */ | ||
49 | - for (n = 0; n < EXYNOS4210_IRQ_GATE_NINPUTS; n++) { | ||
50 | - gate_irq[i][n] = qdev_get_gpio_in(dev, n); | ||
51 | - } | ||
52 | - busdev = SYS_BUS_DEVICE(dev); | ||
53 | - | ||
54 | - /* Connect IRQ Gate output to CPU's IRQ line */ | ||
55 | - sysbus_connect_irq(busdev, 0, | ||
56 | - qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ)); | ||
57 | + DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]); | ||
58 | + object_property_set_int(OBJECT(orgate), "num-lines", | ||
59 | + EXYNOS4210_IRQ_GATE_NINPUTS, | ||
60 | + &error_abort); | ||
61 | + qdev_realize(orgate, NULL, &error_abort); | ||
62 | + qdev_connect_gpio_out(orgate, 0, | ||
63 | + qdev_get_gpio_in(DEVICE(s->cpu[i]), ARM_CPU_IRQ)); | ||
64 | } | ||
65 | |||
66 | /* Private memory region and Internal GIC */ | ||
67 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
68 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
69 | sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR); | ||
70 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | ||
71 | - sysbus_connect_irq(busdev, n, gate_irq[n][0]); | ||
72 | + sysbus_connect_irq(busdev, n, | ||
73 | + qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
74 | } | ||
75 | for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | ||
76 | s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
77 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
78 | /* Map Distributer interface */ | ||
79 | sysbus_mmio_map(busdev, 1, EXYNOS4210_EXT_GIC_DIST_BASE_ADDR); | ||
80 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | ||
81 | - sysbus_connect_irq(busdev, n, gate_irq[n][1]); | ||
82 | + sysbus_connect_irq(busdev, n, | ||
83 | + qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
84 | } | ||
85 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
86 | s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
87 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
88 | object_initialize_child(obj, name, orgate, TYPE_OR_IRQ); | ||
89 | g_free(name); | ||
90 | } | ||
91 | + | ||
92 | + for (i = 0; i < ARRAY_SIZE(s->cpu_irq_orgate); i++) { | ||
93 | + g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i); | ||
94 | + object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); | ||
95 | + } | 111 | + } |
96 | } | 112 | } |
97 | 113 | ||
98 | static void exynos4210_class_init(ObjectClass *klass, void *data) | 114 | static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) |
115 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
116 | Stm32l4x5SocState *s = STM32L4X5_SOC(dev_soc); | ||
117 | const Stm32l4x5SocClass *sc = STM32L4X5_SOC_GET_CLASS(dev_soc); | ||
118 | MemoryRegion *system_memory = get_system_memory(); | ||
119 | - DeviceState *armv7m; | ||
120 | + DeviceState *armv7m, *dev; | ||
121 | SysBusDevice *busdev; | ||
122 | + uint32_t pin_index; | ||
123 | |||
124 | if (!memory_region_init_rom(&s->flash, OBJECT(dev_soc), "flash", | ||
125 | sc->flash_size, errp)) { | ||
126 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | + /* GPIOs */ | ||
131 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { | ||
132 | + g_autofree char *name = g_strdup_printf("%c", 'A' + i); | ||
133 | + dev = DEVICE(&s->gpio[i]); | ||
134 | + qdev_prop_set_string(dev, "name", name); | ||
135 | + qdev_prop_set_uint32(dev, "mode-reset", | ||
136 | + stm32l4x5_gpio_cfg[i].moder_reset); | ||
137 | + qdev_prop_set_uint32(dev, "ospeed-reset", | ||
138 | + stm32l4x5_gpio_cfg[i].ospeedr_reset); | ||
139 | + qdev_prop_set_uint32(dev, "pupd-reset", | ||
140 | + stm32l4x5_gpio_cfg[i].pupdr_reset); | ||
141 | + busdev = SYS_BUS_DEVICE(&s->gpio[i]); | ||
142 | + g_free(name); | ||
143 | + name = g_strdup_printf("gpio%c-out", 'a' + i); | ||
144 | + qdev_connect_clock_in(DEVICE(&s->gpio[i]), "clk", | ||
145 | + qdev_get_clock_out(DEVICE(&(s->rcc)), name)); | ||
146 | + if (!sysbus_realize(busdev, errp)) { | ||
147 | + return; | ||
148 | + } | ||
149 | + sysbus_mmio_map(busdev, 0, stm32l4x5_gpio_cfg[i].addr); | ||
150 | + } | ||
151 | + | ||
152 | /* System configuration controller */ | ||
153 | busdev = SYS_BUS_DEVICE(&s->syscfg); | ||
154 | if (!sysbus_realize(busdev, errp)) { | ||
155 | return; | ||
156 | } | ||
157 | sysbus_mmio_map(busdev, 0, SYSCFG_ADDR); | ||
158 | - /* | ||
159 | - * TODO: when the GPIO device is implemented, connect it | ||
160 | - * to SYCFG using `qdev_connect_gpio_out`, NUM_GPIOS and | ||
161 | - * GPIO_NUM_PINS. | ||
162 | - */ | ||
163 | + | ||
164 | + for (unsigned i = 0; i < NUM_GPIOS; i++) { | ||
165 | + for (unsigned j = 0; j < GPIO_NUM_PINS; j++) { | ||
166 | + pin_index = GPIO_NUM_PINS * i + j; | ||
167 | + qdev_connect_gpio_out(DEVICE(&s->gpio[i]), j, | ||
168 | + qdev_get_gpio_in(DEVICE(&s->syscfg), | ||
169 | + pin_index)); | ||
170 | + } | ||
171 | + } | ||
172 | |||
173 | /* EXTI device */ | ||
174 | busdev = SYS_BUS_DEVICE(&s->exti); | ||
175 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
176 | } | ||
177 | } | ||
178 | |||
179 | - for (unsigned i = 0; i < 16; i++) { | ||
180 | + for (unsigned i = 0; i < GPIO_NUM_PINS; i++) { | ||
181 | qdev_connect_gpio_out(DEVICE(&s->syscfg), i, | ||
182 | qdev_get_gpio_in(DEVICE(&s->exti), i)); | ||
183 | } | ||
184 | @@ -XXX,XX +XXX,XX @@ static void stm32l4x5_soc_realize(DeviceState *dev_soc, Error **errp) | ||
185 | /* RESERVED: 0x40024400, 0x7FDBC00 */ | ||
186 | |||
187 | /* AHB2 BUS */ | ||
188 | - create_unimplemented_device("GPIOA", 0x48000000, 0x400); | ||
189 | - create_unimplemented_device("GPIOB", 0x48000400, 0x400); | ||
190 | - create_unimplemented_device("GPIOC", 0x48000800, 0x400); | ||
191 | - create_unimplemented_device("GPIOD", 0x48000C00, 0x400); | ||
192 | - create_unimplemented_device("GPIOE", 0x48001000, 0x400); | ||
193 | - create_unimplemented_device("GPIOF", 0x48001400, 0x400); | ||
194 | - create_unimplemented_device("GPIOG", 0x48001800, 0x400); | ||
195 | - create_unimplemented_device("GPIOH", 0x48001C00, 0x400); | ||
196 | /* RESERVED: 0x48002000, 0x7FDBC00 */ | ||
197 | create_unimplemented_device("OTG_FS", 0x50000000, 0x40000); | ||
198 | create_unimplemented_device("ADC", 0x50040000, 0x400); | ||
199 | diff --git a/hw/misc/stm32l4x5_syscfg.c b/hw/misc/stm32l4x5_syscfg.c | ||
200 | index XXXXXXX..XXXXXXX 100644 | ||
201 | --- a/hw/misc/stm32l4x5_syscfg.c | ||
202 | +++ b/hw/misc/stm32l4x5_syscfg.c | ||
203 | @@ -XXX,XX +XXX,XX @@ | ||
204 | #include "hw/irq.h" | ||
205 | #include "migration/vmstate.h" | ||
206 | #include "hw/misc/stm32l4x5_syscfg.h" | ||
207 | +#include "hw/gpio/stm32l4x5_gpio.h" | ||
208 | |||
209 | #define SYSCFG_MEMRMP 0x00 | ||
210 | #define SYSCFG_CFGR1 0x04 | ||
211 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
212 | index XXXXXXX..XXXXXXX 100644 | ||
213 | --- a/hw/arm/Kconfig | ||
214 | +++ b/hw/arm/Kconfig | ||
215 | @@ -XXX,XX +XXX,XX @@ config STM32L4X5_SOC | ||
216 | bool | ||
217 | select ARM_V7M | ||
218 | select OR_IRQ | ||
219 | - select STM32L4X5_SYSCFG | ||
220 | select STM32L4X5_EXTI | ||
221 | + select STM32L4X5_SYSCFG | ||
222 | select STM32L4X5_RCC | ||
223 | + select STM32L4X5_GPIO | ||
224 | |||
225 | config XLNX_ZYNQMP_ARM | ||
226 | bool | ||
99 | -- | 227 | -- |
100 | 2.25.1 | 228 | 2.34.1 |
229 | |||
230 | diff view generated by jsdifflib |
1 | Switch the creation of the combiner devices to the new-style | 1 | From: Inès Varhol <ines.varhol@telecom-paris.fr> |
---|---|---|---|
2 | "embedded in state struct" approach, so we can easily refer | ||
3 | to the object elsewhere during realize. | ||
4 | 2 | ||
3 | The testcase contains : | ||
4 | - `test_idr_reset_value()` : | ||
5 | Checks the reset values of MODER, OTYPER, PUPDR, ODR and IDR. | ||
6 | - `test_gpio_output_mode()` : | ||
7 | Checks that writing a bit in register ODR results in the corresponding | ||
8 | pin rising or lowering, if this pin is configured in output mode. | ||
9 | - `test_gpio_input_mode()` : | ||
10 | Checks that a input pin set high or low externally results | ||
11 | in the pin rising and lowering. | ||
12 | - `test_pull_up_pull_down()` : | ||
13 | Checks that a floating pin in pull-up/down mode is actually high/down. | ||
14 | - `test_push_pull()` : | ||
15 | Checks that a pin set externally is disconnected when configured in | ||
16 | push-pull output mode, and can't be set externally while in this mode. | ||
17 | - `test_open_drain()` : | ||
18 | Checks that a pin set externally high is disconnected when configured | ||
19 | in open-drain output mode, and can't be set high while in this mode. | ||
20 | - `test_bsrr_brr()` : | ||
21 | Checks that writing to BSRR and BRR has the desired result in ODR. | ||
22 | - `test_clock_enable()` : | ||
23 | Checks that GPIO clock is at the right frequency after enabling it. | ||
24 | |||
25 | Acked-by: Thomas Huth <thuth@redhat.com> | ||
26 | Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> | ||
27 | Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> | ||
28 | Message-id: 20240305210444.310665-4-ines.varhol@telecom-paris.fr | ||
5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 29 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220404154658.565020-18-peter.maydell@linaro.org | ||
8 | --- | 30 | --- |
9 | include/hw/arm/exynos4210.h | 3 ++ | 31 | tests/qtest/stm32l4x5_gpio-test.c | 551 ++++++++++++++++++++++++++++++ |
10 | include/hw/intc/exynos4210_combiner.h | 57 +++++++++++++++++++++++++++ | 32 | tests/qtest/meson.build | 3 +- |
11 | hw/arm/exynos4210.c | 20 +++++----- | 33 | 2 files changed, 553 insertions(+), 1 deletion(-) |
12 | hw/intc/exynos4210_combiner.c | 31 +-------------- | 34 | create mode 100644 tests/qtest/stm32l4x5_gpio-test.c |
13 | 4 files changed, 72 insertions(+), 39 deletions(-) | ||
14 | create mode 100644 include/hw/intc/exynos4210_combiner.h | ||
15 | 35 | ||
16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | 36 | diff --git a/tests/qtest/stm32l4x5_gpio-test.c b/tests/qtest/stm32l4x5_gpio-test.c |
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/exynos4210.h | ||
19 | +++ b/include/hw/arm/exynos4210.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "hw/sysbus.h" | ||
22 | #include "hw/cpu/a9mpcore.h" | ||
23 | #include "hw/intc/exynos4210_gic.h" | ||
24 | +#include "hw/intc/exynos4210_combiner.h" | ||
25 | #include "hw/core/split-irq.h" | ||
26 | #include "target/arm/cpu-qom.h" | ||
27 | #include "qom/object.h" | ||
28 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
29 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
30 | A9MPPrivState a9mpcore; | ||
31 | Exynos4210GicState ext_gic; | ||
32 | + Exynos4210CombinerState int_combiner; | ||
33 | + Exynos4210CombinerState ext_combiner; | ||
34 | SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS]; | ||
35 | }; | ||
36 | |||
37 | diff --git a/include/hw/intc/exynos4210_combiner.h b/include/hw/intc/exynos4210_combiner.h | ||
38 | new file mode 100644 | 37 | new file mode 100644 |
39 | index XXXXXXX..XXXXXXX | 38 | index XXXXXXX..XXXXXXX |
40 | --- /dev/null | 39 | --- /dev/null |
41 | +++ b/include/hw/intc/exynos4210_combiner.h | 40 | +++ b/tests/qtest/stm32l4x5_gpio-test.c |
42 | @@ -XXX,XX +XXX,XX @@ | 41 | @@ -XXX,XX +XXX,XX @@ |
43 | +/* | 42 | +/* |
44 | + * Samsung exynos4210 Interrupt Combiner | 43 | + * QTest testcase for STM32L4x5_GPIO |
45 | + * | 44 | + * |
46 | + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. | 45 | + * Copyright (c) 2024 Arnaud Minier <arnaud.minier@telecom-paris.fr> |
47 | + * All rights reserved. | 46 | + * Copyright (c) 2024 Inès Varhol <ines.varhol@telecom-paris.fr> |
48 | + * | 47 | + * |
49 | + * Evgeny Voevodin <e.voevodin@samsung.com> | 48 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. |
50 | + * | 49 | + * See the COPYING file in the top-level directory. |
51 | + * This program is free software; you can redistribute it and/or modify it | ||
52 | + * under the terms of the GNU General Public License as published by the | ||
53 | + * Free Software Foundation; either version 2 of the License, or (at your | ||
54 | + * option) any later version. | ||
55 | + * | ||
56 | + * This program is distributed in the hope that it will be useful, | ||
57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
59 | + * See the GNU General Public License for more details. | ||
60 | + * | ||
61 | + * You should have received a copy of the GNU General Public License along | ||
62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
63 | + */ | 50 | + */ |
64 | + | 51 | + |
65 | +#ifndef HW_INTC_EXYNOS4210_COMBINER | 52 | +#include "qemu/osdep.h" |
66 | +#define HW_INTC_EXYNOS4210_COMBINER | 53 | +#include "libqtest-single.h" |
67 | + | 54 | + |
68 | +#include "hw/sysbus.h" | 55 | +#define GPIO_BASE_ADDR 0x48000000 |
69 | + | 56 | +#define GPIO_SIZE 0x400 |
70 | +/* | 57 | +#define NUM_GPIOS 8 |
71 | + * State for each output signal of internal combiner | 58 | +#define NUM_GPIO_PINS 16 |
72 | + */ | 59 | + |
73 | +typedef struct CombinerGroupState { | 60 | +#define GPIO_A 0x48000000 |
74 | + uint8_t src_mask; /* 1 - source enabled, 0 - disabled */ | 61 | +#define GPIO_B 0x48000400 |
75 | + uint8_t src_pending; /* Pending source interrupts before masking */ | 62 | +#define GPIO_C 0x48000800 |
76 | +} CombinerGroupState; | 63 | +#define GPIO_D 0x48000C00 |
77 | + | 64 | +#define GPIO_E 0x48001000 |
78 | +#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner" | 65 | +#define GPIO_F 0x48001400 |
79 | +OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER) | 66 | +#define GPIO_G 0x48001800 |
80 | + | 67 | +#define GPIO_H 0x48001C00 |
81 | +/* Number of groups and total number of interrupts for the internal combiner */ | 68 | + |
82 | +#define IIC_NGRP 64 | 69 | +#define MODER 0x00 |
83 | +#define IIC_NIRQ (IIC_NGRP * 8) | 70 | +#define OTYPER 0x04 |
84 | +#define IIC_REGSET_SIZE 0x41 | 71 | +#define PUPDR 0x0C |
85 | + | 72 | +#define IDR 0x10 |
86 | +struct Exynos4210CombinerState { | 73 | +#define ODR 0x14 |
87 | + SysBusDevice parent_obj; | 74 | +#define BSRR 0x18 |
88 | + | 75 | +#define BRR 0x28 |
89 | + MemoryRegion iomem; | 76 | + |
90 | + | 77 | +#define MODER_INPUT 0 |
91 | + struct CombinerGroupState group[IIC_NGRP]; | 78 | +#define MODER_OUTPUT 1 |
92 | + uint32_t reg_set[IIC_REGSET_SIZE]; | 79 | + |
93 | + uint32_t icipsr[2]; | 80 | +#define PUPDR_NONE 0 |
94 | + uint32_t external; /* 1 means that this combiner is external */ | 81 | +#define PUPDR_PULLUP 1 |
95 | + | 82 | +#define PUPDR_PULLDOWN 2 |
96 | + qemu_irq output_irq[IIC_NGRP]; | 83 | + |
84 | +#define OTYPER_PUSH_PULL 0 | ||
85 | +#define OTYPER_OPEN_DRAIN 1 | ||
86 | + | ||
87 | +const uint32_t moder_reset[NUM_GPIOS] = { | ||
88 | + 0xABFFFFFF, | ||
89 | + 0xFFFFFEBF, | ||
90 | + 0xFFFFFFFF, | ||
91 | + 0xFFFFFFFF, | ||
92 | + 0xFFFFFFFF, | ||
93 | + 0xFFFFFFFF, | ||
94 | + 0xFFFFFFFF, | ||
95 | + 0x0000000F | ||
97 | +}; | 96 | +}; |
98 | + | 97 | + |
99 | +#endif | 98 | +const uint32_t pupdr_reset[NUM_GPIOS] = { |
100 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | 99 | + 0x64000000, |
100 | + 0x00000100, | ||
101 | + 0x00000000, | ||
102 | + 0x00000000, | ||
103 | + 0x00000000, | ||
104 | + 0x00000000, | ||
105 | + 0x00000000, | ||
106 | + 0x00000000 | ||
107 | +}; | ||
108 | + | ||
109 | +const uint32_t idr_reset[NUM_GPIOS] = { | ||
110 | + 0x0000A000, | ||
111 | + 0x00000010, | ||
112 | + 0x00000000, | ||
113 | + 0x00000000, | ||
114 | + 0x00000000, | ||
115 | + 0x00000000, | ||
116 | + 0x00000000, | ||
117 | + 0x00000000 | ||
118 | +}; | ||
119 | + | ||
120 | +static uint32_t gpio_readl(unsigned int gpio, unsigned int offset) | ||
121 | +{ | ||
122 | + return readl(gpio + offset); | ||
123 | +} | ||
124 | + | ||
125 | +static void gpio_writel(unsigned int gpio, unsigned int offset, uint32_t value) | ||
126 | +{ | ||
127 | + writel(gpio + offset, value); | ||
128 | +} | ||
129 | + | ||
130 | +static void gpio_set_bit(unsigned int gpio, unsigned int reg, | ||
131 | + unsigned int pin, uint32_t value) | ||
132 | +{ | ||
133 | + uint32_t mask = 0xFFFFFFFF & ~(0x1 << pin); | ||
134 | + gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << pin); | ||
135 | +} | ||
136 | + | ||
137 | +static void gpio_set_2bits(unsigned int gpio, unsigned int reg, | ||
138 | + unsigned int pin, uint32_t value) | ||
139 | +{ | ||
140 | + uint32_t offset = 2 * pin; | ||
141 | + uint32_t mask = 0xFFFFFFFF & ~(0x3 << offset); | ||
142 | + gpio_writel(gpio, reg, (gpio_readl(gpio, reg) & mask) | value << offset); | ||
143 | +} | ||
144 | + | ||
145 | +static unsigned int get_gpio_id(uint32_t gpio_addr) | ||
146 | +{ | ||
147 | + return (gpio_addr - GPIO_BASE_ADDR) / GPIO_SIZE; | ||
148 | +} | ||
149 | + | ||
150 | +static void gpio_set_irq(unsigned int gpio, int num, int level) | ||
151 | +{ | ||
152 | + g_autofree char *name = g_strdup_printf("/machine/soc/gpio%c", | ||
153 | + get_gpio_id(gpio) + 'a'); | ||
154 | + qtest_set_irq_in(global_qtest, name, NULL, num, level); | ||
155 | +} | ||
156 | + | ||
157 | +static void disconnect_all_pins(unsigned int gpio) | ||
158 | +{ | ||
159 | + g_autofree char *path = g_strdup_printf("/machine/soc/gpio%c", | ||
160 | + get_gpio_id(gpio) + 'a'); | ||
161 | + QDict *r; | ||
162 | + | ||
163 | + r = qtest_qmp(global_qtest, "{ 'execute': 'qom-set', 'arguments': " | ||
164 | + "{ 'path': %s, 'property': 'disconnected-pins', 'value': %d } }", | ||
165 | + path, 0xFFFF); | ||
166 | + g_assert_false(qdict_haskey(r, "error")); | ||
167 | + qobject_unref(r); | ||
168 | +} | ||
169 | + | ||
170 | +static uint32_t get_disconnected_pins(unsigned int gpio) | ||
171 | +{ | ||
172 | + g_autofree char *path = g_strdup_printf("/machine/soc/gpio%c", | ||
173 | + get_gpio_id(gpio) + 'a'); | ||
174 | + uint32_t disconnected_pins = 0; | ||
175 | + QDict *r; | ||
176 | + | ||
177 | + r = qtest_qmp(global_qtest, "{ 'execute': 'qom-get', 'arguments':" | ||
178 | + " { 'path': %s, 'property': 'disconnected-pins'} }", path); | ||
179 | + g_assert_false(qdict_haskey(r, "error")); | ||
180 | + disconnected_pins = qdict_get_int(r, "return"); | ||
181 | + qobject_unref(r); | ||
182 | + return disconnected_pins; | ||
183 | +} | ||
184 | + | ||
185 | +static uint32_t reset(uint32_t gpio, unsigned int offset) | ||
186 | +{ | ||
187 | + switch (offset) { | ||
188 | + case MODER: | ||
189 | + return moder_reset[get_gpio_id(gpio)]; | ||
190 | + case PUPDR: | ||
191 | + return pupdr_reset[get_gpio_id(gpio)]; | ||
192 | + case IDR: | ||
193 | + return idr_reset[get_gpio_id(gpio)]; | ||
194 | + } | ||
195 | + return 0x0; | ||
196 | +} | ||
197 | + | ||
198 | +static void system_reset(void) | ||
199 | +{ | ||
200 | + QDict *r; | ||
201 | + r = qtest_qmp(global_qtest, "{'execute': 'system_reset'}"); | ||
202 | + g_assert_false(qdict_haskey(r, "error")); | ||
203 | + qobject_unref(r); | ||
204 | +} | ||
205 | + | ||
206 | +static void test_idr_reset_value(void) | ||
207 | +{ | ||
208 | + /* | ||
209 | + * Checks that the values in MODER, OTYPER, PUPDR and ODR | ||
210 | + * after reset are correct, and that the value in IDR is | ||
211 | + * coherent. | ||
212 | + * Since AF and analog modes aren't implemented, IDR reset | ||
213 | + * values aren't the same as with a real board. | ||
214 | + * | ||
215 | + * Register IDR contains the actual values of all GPIO pins. | ||
216 | + * Its value depends on the pins' configuration | ||
217 | + * (intput/output/analog : register MODER, push-pull/open-drain : | ||
218 | + * register OTYPER, pull-up/pull-down/none : register PUPDR) | ||
219 | + * and on the values stored in register ODR | ||
220 | + * (in case the pin is in output mode). | ||
221 | + */ | ||
222 | + | ||
223 | + gpio_writel(GPIO_A, MODER, 0xDEADBEEF); | ||
224 | + gpio_writel(GPIO_A, ODR, 0xDEADBEEF); | ||
225 | + gpio_writel(GPIO_A, OTYPER, 0xDEADBEEF); | ||
226 | + gpio_writel(GPIO_A, PUPDR, 0xDEADBEEF); | ||
227 | + | ||
228 | + gpio_writel(GPIO_B, MODER, 0xDEADBEEF); | ||
229 | + gpio_writel(GPIO_B, ODR, 0xDEADBEEF); | ||
230 | + gpio_writel(GPIO_B, OTYPER, 0xDEADBEEF); | ||
231 | + gpio_writel(GPIO_B, PUPDR, 0xDEADBEEF); | ||
232 | + | ||
233 | + gpio_writel(GPIO_C, MODER, 0xDEADBEEF); | ||
234 | + gpio_writel(GPIO_C, ODR, 0xDEADBEEF); | ||
235 | + gpio_writel(GPIO_C, OTYPER, 0xDEADBEEF); | ||
236 | + gpio_writel(GPIO_C, PUPDR, 0xDEADBEEF); | ||
237 | + | ||
238 | + gpio_writel(GPIO_H, MODER, 0xDEADBEEF); | ||
239 | + gpio_writel(GPIO_H, ODR, 0xDEADBEEF); | ||
240 | + gpio_writel(GPIO_H, OTYPER, 0xDEADBEEF); | ||
241 | + gpio_writel(GPIO_H, PUPDR, 0xDEADBEEF); | ||
242 | + | ||
243 | + system_reset(); | ||
244 | + | ||
245 | + uint32_t moder = gpio_readl(GPIO_A, MODER); | ||
246 | + uint32_t odr = gpio_readl(GPIO_A, ODR); | ||
247 | + uint32_t otyper = gpio_readl(GPIO_A, OTYPER); | ||
248 | + uint32_t pupdr = gpio_readl(GPIO_A, PUPDR); | ||
249 | + uint32_t idr = gpio_readl(GPIO_A, IDR); | ||
250 | + /* 15: AF, 14: AF, 13: AF, 12: Analog ... */ | ||
251 | + /* here AF is the same as Analog and Input mode */ | ||
252 | + g_assert_cmphex(moder, ==, reset(GPIO_A, MODER)); | ||
253 | + g_assert_cmphex(odr, ==, reset(GPIO_A, ODR)); | ||
254 | + g_assert_cmphex(otyper, ==, reset(GPIO_A, OTYPER)); | ||
255 | + /* 15: pull-up, 14: pull-down, 13: pull-up, 12: neither ... */ | ||
256 | + g_assert_cmphex(pupdr, ==, reset(GPIO_A, PUPDR)); | ||
257 | + /* 15 : 1, 14: 0, 13: 1, 12 : reset value ... */ | ||
258 | + g_assert_cmphex(idr, ==, reset(GPIO_A, IDR)); | ||
259 | + | ||
260 | + moder = gpio_readl(GPIO_B, MODER); | ||
261 | + odr = gpio_readl(GPIO_B, ODR); | ||
262 | + otyper = gpio_readl(GPIO_B, OTYPER); | ||
263 | + pupdr = gpio_readl(GPIO_B, PUPDR); | ||
264 | + idr = gpio_readl(GPIO_B, IDR); | ||
265 | + /* ... 5: Analog, 4: AF, 3: AF, 2: Analog ... */ | ||
266 | + /* here AF is the same as Analog and Input mode */ | ||
267 | + g_assert_cmphex(moder, ==, reset(GPIO_B, MODER)); | ||
268 | + g_assert_cmphex(odr, ==, reset(GPIO_B, ODR)); | ||
269 | + g_assert_cmphex(otyper, ==, reset(GPIO_B, OTYPER)); | ||
270 | + /* ... 5: neither, 4: pull-up, 3: neither ... */ | ||
271 | + g_assert_cmphex(pupdr, ==, reset(GPIO_B, PUPDR)); | ||
272 | + /* ... 5 : reset value, 4 : 1, 3 : reset value ... */ | ||
273 | + g_assert_cmphex(idr, ==, reset(GPIO_B, IDR)); | ||
274 | + | ||
275 | + moder = gpio_readl(GPIO_C, MODER); | ||
276 | + odr = gpio_readl(GPIO_C, ODR); | ||
277 | + otyper = gpio_readl(GPIO_C, OTYPER); | ||
278 | + pupdr = gpio_readl(GPIO_C, PUPDR); | ||
279 | + idr = gpio_readl(GPIO_C, IDR); | ||
280 | + /* Analog, same as Input mode*/ | ||
281 | + g_assert_cmphex(moder, ==, reset(GPIO_C, MODER)); | ||
282 | + g_assert_cmphex(odr, ==, reset(GPIO_C, ODR)); | ||
283 | + g_assert_cmphex(otyper, ==, reset(GPIO_C, OTYPER)); | ||
284 | + /* no pull-up or pull-down */ | ||
285 | + g_assert_cmphex(pupdr, ==, reset(GPIO_C, PUPDR)); | ||
286 | + /* reset value */ | ||
287 | + g_assert_cmphex(idr, ==, reset(GPIO_C, IDR)); | ||
288 | + | ||
289 | + moder = gpio_readl(GPIO_H, MODER); | ||
290 | + odr = gpio_readl(GPIO_H, ODR); | ||
291 | + otyper = gpio_readl(GPIO_H, OTYPER); | ||
292 | + pupdr = gpio_readl(GPIO_H, PUPDR); | ||
293 | + idr = gpio_readl(GPIO_H, IDR); | ||
294 | + /* Analog, same as Input mode */ | ||
295 | + g_assert_cmphex(moder, ==, reset(GPIO_H, MODER)); | ||
296 | + g_assert_cmphex(odr, ==, reset(GPIO_H, ODR)); | ||
297 | + g_assert_cmphex(otyper, ==, reset(GPIO_H, OTYPER)); | ||
298 | + /* no pull-up or pull-down */ | ||
299 | + g_assert_cmphex(pupdr, ==, reset(GPIO_H, PUPDR)); | ||
300 | + /* reset value */ | ||
301 | + g_assert_cmphex(idr, ==, reset(GPIO_H, IDR)); | ||
302 | +} | ||
303 | + | ||
304 | +static void test_gpio_output_mode(const void *data) | ||
305 | +{ | ||
306 | + /* | ||
307 | + * Checks that setting a bit in ODR sets the corresponding | ||
308 | + * GPIO line high : it should set the right bit in IDR | ||
309 | + * and send an irq to syscfg. | ||
310 | + * Additionally, it checks that values written to ODR | ||
311 | + * when not in output mode are stored and not discarded. | ||
312 | + */ | ||
313 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
314 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
315 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
316 | + | ||
317 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
318 | + | ||
319 | + /* Set a bit in ODR and check nothing happens */ | ||
320 | + gpio_set_bit(gpio, ODR, pin, 1); | ||
321 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
322 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
323 | + | ||
324 | + /* Configure the relevant line as output and check the pin is high */ | ||
325 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
326 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
327 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
328 | + | ||
329 | + /* Reset the bit in ODR and check the pin is low */ | ||
330 | + gpio_set_bit(gpio, ODR, pin, 0); | ||
331 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
332 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
333 | + | ||
334 | + /* Clean the test */ | ||
335 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
336 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
337 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
338 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
339 | +} | ||
340 | + | ||
341 | +static void test_gpio_input_mode(const void *data) | ||
342 | +{ | ||
343 | + /* | ||
344 | + * Test that setting a line high/low externally sets the | ||
345 | + * corresponding GPIO line high/low : it should set the | ||
346 | + * right bit in IDR and send an irq to syscfg. | ||
347 | + */ | ||
348 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
349 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
350 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
351 | + | ||
352 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
353 | + | ||
354 | + /* Configure a line as input, raise it, and check that the pin is high */ | ||
355 | + gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
356 | + gpio_set_irq(gpio, pin, 1); | ||
357 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
358 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
359 | + | ||
360 | + /* Lower the line and check that the pin is low */ | ||
361 | + gpio_set_irq(gpio, pin, 0); | ||
362 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
363 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
364 | + | ||
365 | + /* Clean the test */ | ||
366 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
367 | + disconnect_all_pins(gpio); | ||
368 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
369 | +} | ||
370 | + | ||
371 | +static void test_pull_up_pull_down(const void *data) | ||
372 | +{ | ||
373 | + /* | ||
374 | + * Test that a floating pin with pull-up sets the pin | ||
375 | + * high and vice-versa. | ||
376 | + */ | ||
377 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
378 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
379 | + unsigned int gpio_id = get_gpio_id(gpio); | ||
380 | + | ||
381 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
382 | + | ||
383 | + /* Configure a line as input with pull-up, check the line is set high */ | ||
384 | + gpio_set_2bits(gpio, MODER, pin, MODER_INPUT); | ||
385 | + gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLUP); | ||
386 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) | (1 << pin)); | ||
387 | + g_assert_true(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
388 | + | ||
389 | + /* Configure the line with pull-down, check the line is low */ | ||
390 | + gpio_set_2bits(gpio, PUPDR, pin, PUPDR_PULLDOWN); | ||
391 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
392 | + g_assert_false(get_irq(gpio_id * NUM_GPIO_PINS + pin)); | ||
393 | + | ||
394 | + /* Clean the test */ | ||
395 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
396 | + gpio_writel(gpio, PUPDR, reset(gpio, PUPDR)); | ||
397 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
398 | +} | ||
399 | + | ||
400 | +static void test_push_pull(const void *data) | ||
401 | +{ | ||
402 | + /* | ||
403 | + * Test that configuring a line in push-pull output mode | ||
404 | + * disconnects the pin, that the pin can't be set or reset | ||
405 | + * externally afterwards. | ||
406 | + */ | ||
407 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
408 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
409 | + uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
410 | + | ||
411 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
412 | + | ||
413 | + /* Setting a line high externally, configuring it in push-pull output */ | ||
414 | + /* And checking the pin was disconnected */ | ||
415 | + gpio_set_irq(gpio, pin, 1); | ||
416 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
417 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
418 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
419 | + | ||
420 | + /* Setting a line low externally, configuring it in push-pull output */ | ||
421 | + /* And checking the pin was disconnected */ | ||
422 | + gpio_set_irq(gpio2, pin, 0); | ||
423 | + gpio_set_bit(gpio2, ODR, pin, 1); | ||
424 | + gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); | ||
425 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); | ||
426 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); | ||
427 | + | ||
428 | + /* Trying to set a push-pull output pin, checking it doesn't work */ | ||
429 | + gpio_set_irq(gpio, pin, 1); | ||
430 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
431 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
432 | + | ||
433 | + /* Trying to reset a push-pull output pin, checking it doesn't work */ | ||
434 | + gpio_set_irq(gpio2, pin, 0); | ||
435 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF); | ||
436 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR) | (1 << pin)); | ||
437 | + | ||
438 | + /* Clean the test */ | ||
439 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
440 | + gpio_writel(gpio2, ODR, reset(gpio2, ODR)); | ||
441 | + gpio_writel(gpio2, MODER, reset(gpio2, MODER)); | ||
442 | +} | ||
443 | + | ||
444 | +static void test_open_drain(const void *data) | ||
445 | +{ | ||
446 | + /* | ||
447 | + * Test that configuring a line in open-drain output mode | ||
448 | + * disconnects a pin set high externally and that the pin | ||
449 | + * can't be set high externally while configured in open-drain. | ||
450 | + * | ||
451 | + * However a pin set low externally shouldn't be disconnected, | ||
452 | + * and it can be set low externally when in open-drain mode. | ||
453 | + */ | ||
454 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
455 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
456 | + uint32_t gpio2 = GPIO_BASE_ADDR + (GPIO_H - gpio); | ||
457 | + | ||
458 | + qtest_irq_intercept_in(global_qtest, "/machine/soc/syscfg"); | ||
459 | + | ||
460 | + /* Setting a line high externally, configuring it in open-drain output */ | ||
461 | + /* And checking the pin was disconnected */ | ||
462 | + gpio_set_irq(gpio, pin, 1); | ||
463 | + gpio_set_bit(gpio, OTYPER, pin, OTYPER_OPEN_DRAIN); | ||
464 | + gpio_set_2bits(gpio, MODER, pin, MODER_OUTPUT); | ||
465 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
466 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
467 | + | ||
468 | + /* Setting a line low externally, configuring it in open-drain output */ | ||
469 | + /* And checking the pin wasn't disconnected */ | ||
470 | + gpio_set_irq(gpio2, pin, 0); | ||
471 | + gpio_set_bit(gpio2, ODR, pin, 1); | ||
472 | + gpio_set_bit(gpio2, OTYPER, pin, OTYPER_OPEN_DRAIN); | ||
473 | + gpio_set_2bits(gpio2, MODER, pin, MODER_OUTPUT); | ||
474 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); | ||
475 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, | ||
476 | + reset(gpio2, IDR) & ~(1 << pin)); | ||
477 | + | ||
478 | + /* Trying to set a open-drain output pin, checking it doesn't work */ | ||
479 | + gpio_set_irq(gpio, pin, 1); | ||
480 | + g_assert_cmphex(get_disconnected_pins(gpio), ==, 0xFFFF); | ||
481 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR) & ~(1 << pin)); | ||
482 | + | ||
483 | + /* Trying to reset a open-drain output pin, checking it works */ | ||
484 | + gpio_set_bit(gpio, ODR, pin, 1); | ||
485 | + gpio_set_irq(gpio, pin, 0); | ||
486 | + g_assert_cmphex(get_disconnected_pins(gpio2), ==, 0xFFFF & ~(1 << pin)); | ||
487 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, | ||
488 | + reset(gpio2, IDR) & ~(1 << pin)); | ||
489 | + | ||
490 | + /* Clean the test */ | ||
491 | + disconnect_all_pins(gpio2); | ||
492 | + gpio_writel(gpio2, OTYPER, reset(gpio2, OTYPER)); | ||
493 | + gpio_writel(gpio2, ODR, reset(gpio2, ODR)); | ||
494 | + gpio_writel(gpio2, MODER, reset(gpio2, MODER)); | ||
495 | + g_assert_cmphex(gpio_readl(gpio2, IDR), ==, reset(gpio2, IDR)); | ||
496 | + disconnect_all_pins(gpio); | ||
497 | + gpio_writel(gpio, OTYPER, reset(gpio, OTYPER)); | ||
498 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
499 | + gpio_writel(gpio, MODER, reset(gpio, MODER)); | ||
500 | + g_assert_cmphex(gpio_readl(gpio, IDR), ==, reset(gpio, IDR)); | ||
501 | +} | ||
502 | + | ||
503 | +static void test_bsrr_brr(const void *data) | ||
504 | +{ | ||
505 | + /* | ||
506 | + * Test that writing a '1' in BSS and BSRR | ||
507 | + * has the desired effect on ODR. | ||
508 | + * In BSRR, BSx has priority over BRx. | ||
509 | + */ | ||
510 | + unsigned int pin = ((uint64_t)data) & 0xF; | ||
511 | + uint32_t gpio = ((uint64_t)data) >> 32; | ||
512 | + | ||
513 | + gpio_writel(gpio, BSRR, (1 << pin)); | ||
514 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
515 | + | ||
516 | + gpio_writel(gpio, BSRR, (1 << (pin + NUM_GPIO_PINS))); | ||
517 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
518 | + | ||
519 | + gpio_writel(gpio, BSRR, (1 << pin)); | ||
520 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
521 | + | ||
522 | + gpio_writel(gpio, BRR, (1 << pin)); | ||
523 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
524 | + | ||
525 | + /* BSx should have priority over BRx */ | ||
526 | + gpio_writel(gpio, BSRR, (1 << pin) | (1 << (pin + NUM_GPIO_PINS))); | ||
527 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR) | (1 << pin)); | ||
528 | + | ||
529 | + gpio_writel(gpio, BRR, (1 << pin)); | ||
530 | + g_assert_cmphex(gpio_readl(gpio, ODR), ==, reset(gpio, ODR)); | ||
531 | + | ||
532 | + gpio_writel(gpio, ODR, reset(gpio, ODR)); | ||
533 | +} | ||
534 | + | ||
535 | +int main(int argc, char **argv) | ||
536 | +{ | ||
537 | + int ret; | ||
538 | + | ||
539 | + g_test_init(&argc, &argv, NULL); | ||
540 | + g_test_set_nonfatal_assertions(); | ||
541 | + qtest_add_func("stm32l4x5/gpio/test_idr_reset_value", | ||
542 | + test_idr_reset_value); | ||
543 | + /* | ||
544 | + * The inputs for the tests (gpio and pin) can be changed, | ||
545 | + * but the tests don't work for pins that are high at reset | ||
546 | + * (GPIOA15, GPIO13 and GPIOB5). | ||
547 | + * Specifically, rising the pin then checking `get_irq()` | ||
548 | + * is problematic since the pin was already high. | ||
549 | + */ | ||
550 | + qtest_add_data_func("stm32l4x5/gpio/test_gpioc5_output_mode", | ||
551 | + (void *)((uint64_t)GPIO_C << 32 | 5), | ||
552 | + test_gpio_output_mode); | ||
553 | + qtest_add_data_func("stm32l4x5/gpio/test_gpioh3_output_mode", | ||
554 | + (void *)((uint64_t)GPIO_H << 32 | 3), | ||
555 | + test_gpio_output_mode); | ||
556 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode1", | ||
557 | + (void *)((uint64_t)GPIO_D << 32 | 6), | ||
558 | + test_gpio_input_mode); | ||
559 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_input_mode2", | ||
560 | + (void *)((uint64_t)GPIO_C << 32 | 10), | ||
561 | + test_gpio_input_mode); | ||
562 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down1", | ||
563 | + (void *)((uint64_t)GPIO_B << 32 | 5), | ||
564 | + test_pull_up_pull_down); | ||
565 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_pull_up_pull_down2", | ||
566 | + (void *)((uint64_t)GPIO_F << 32 | 1), | ||
567 | + test_pull_up_pull_down); | ||
568 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull1", | ||
569 | + (void *)((uint64_t)GPIO_G << 32 | 6), | ||
570 | + test_push_pull); | ||
571 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_push_pull2", | ||
572 | + (void *)((uint64_t)GPIO_H << 32 | 3), | ||
573 | + test_push_pull); | ||
574 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain1", | ||
575 | + (void *)((uint64_t)GPIO_C << 32 | 4), | ||
576 | + test_open_drain); | ||
577 | + qtest_add_data_func("stm32l4x5/gpio/test_gpio_open_drain2", | ||
578 | + (void *)((uint64_t)GPIO_E << 32 | 11), | ||
579 | + test_open_drain); | ||
580 | + qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr1", | ||
581 | + (void *)((uint64_t)GPIO_A << 32 | 12), | ||
582 | + test_bsrr_brr); | ||
583 | + qtest_add_data_func("stm32l4x5/gpio/test_bsrr_brr2", | ||
584 | + (void *)((uint64_t)GPIO_D << 32 | 0), | ||
585 | + test_bsrr_brr); | ||
586 | + | ||
587 | + qtest_start("-machine b-l475e-iot01a"); | ||
588 | + ret = g_test_run(); | ||
589 | + qtest_end(); | ||
590 | + | ||
591 | + return ret; | ||
592 | +} | ||
593 | diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build | ||
101 | index XXXXXXX..XXXXXXX 100644 | 594 | index XXXXXXX..XXXXXXX 100644 |
102 | --- a/hw/arm/exynos4210.c | 595 | --- a/tests/qtest/meson.build |
103 | +++ b/hw/arm/exynos4210.c | 596 | +++ b/tests/qtest/meson.build |
104 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | 597 | @@ -XXX,XX +XXX,XX @@ qtests_aspeed = \ |
105 | } | 598 | qtests_stm32l4x5 = \ |
106 | 599 | ['stm32l4x5_exti-test', | |
107 | /* Internal Interrupt Combiner */ | 600 | 'stm32l4x5_syscfg-test', |
108 | - dev = qdev_new("exynos4210.combiner"); | 601 | - 'stm32l4x5_rcc-test'] |
109 | - busdev = SYS_BUS_DEVICE(dev); | 602 | + 'stm32l4x5_rcc-test', |
110 | - sysbus_realize_and_unref(busdev, &error_fatal); | 603 | + 'stm32l4x5_gpio-test'] |
111 | + busdev = SYS_BUS_DEVICE(&s->int_combiner); | 604 | |
112 | + sysbus_realize(busdev, &error_fatal); | 605 | qtests_arm = \ |
113 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | 606 | (config_all_devices.has_key('CONFIG_MPS2') ? ['sse-timer-test'] : []) + \ |
114 | sysbus_connect_irq(busdev, n, | ||
115 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
116 | } | ||
117 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); | ||
118 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0); | ||
119 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); | ||
120 | |||
121 | /* External Interrupt Combiner */ | ||
122 | - dev = qdev_new("exynos4210.combiner"); | ||
123 | - qdev_prop_set_uint32(dev, "external", 1); | ||
124 | - busdev = SYS_BUS_DEVICE(dev); | ||
125 | - sysbus_realize_and_unref(busdev, &error_fatal); | ||
126 | + qdev_prop_set_uint32(DEVICE(&s->ext_combiner), "external", 1); | ||
127 | + busdev = SYS_BUS_DEVICE(&s->ext_combiner); | ||
128 | + sysbus_realize(busdev, &error_fatal); | ||
129 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
130 | sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
131 | } | ||
132 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); | ||
133 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1); | ||
134 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
135 | |||
136 | /* Initialize board IRQs. */ | ||
137 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
138 | |||
139 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
140 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | ||
141 | + object_initialize_child(obj, "int-combiner", &s->int_combiner, | ||
142 | + TYPE_EXYNOS4210_COMBINER); | ||
143 | + object_initialize_child(obj, "ext-combiner", &s->ext_combiner, | ||
144 | + TYPE_EXYNOS4210_COMBINER); | ||
145 | } | ||
146 | |||
147 | static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
148 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c | ||
149 | index XXXXXXX..XXXXXXX 100644 | ||
150 | --- a/hw/intc/exynos4210_combiner.c | ||
151 | +++ b/hw/intc/exynos4210_combiner.c | ||
152 | @@ -XXX,XX +XXX,XX @@ | ||
153 | #include "hw/sysbus.h" | ||
154 | #include "migration/vmstate.h" | ||
155 | #include "qemu/module.h" | ||
156 | - | ||
157 | +#include "hw/intc/exynos4210_combiner.h" | ||
158 | #include "hw/arm/exynos4210.h" | ||
159 | #include "hw/hw.h" | ||
160 | #include "hw/irq.h" | ||
161 | @@ -XXX,XX +XXX,XX @@ | ||
162 | #define DPRINTF(fmt, ...) do {} while (0) | ||
163 | #endif | ||
164 | |||
165 | -#define IIC_NGRP 64 /* Internal Interrupt Combiner | ||
166 | - Groups number */ | ||
167 | -#define IIC_NIRQ (IIC_NGRP * 8)/* Internal Interrupt Combiner | ||
168 | - Interrupts number */ | ||
169 | #define IIC_REGION_SIZE 0x108 /* Size of memory mapped region */ | ||
170 | -#define IIC_REGSET_SIZE 0x41 | ||
171 | - | ||
172 | -/* | ||
173 | - * State for each output signal of internal combiner | ||
174 | - */ | ||
175 | -typedef struct CombinerGroupState { | ||
176 | - uint8_t src_mask; /* 1 - source enabled, 0 - disabled */ | ||
177 | - uint8_t src_pending; /* Pending source interrupts before masking */ | ||
178 | -} CombinerGroupState; | ||
179 | - | ||
180 | -#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner" | ||
181 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER) | ||
182 | - | ||
183 | -struct Exynos4210CombinerState { | ||
184 | - SysBusDevice parent_obj; | ||
185 | - | ||
186 | - MemoryRegion iomem; | ||
187 | - | ||
188 | - struct CombinerGroupState group[IIC_NGRP]; | ||
189 | - uint32_t reg_set[IIC_REGSET_SIZE]; | ||
190 | - uint32_t icipsr[2]; | ||
191 | - uint32_t external; /* 1 means that this combiner is external */ | ||
192 | - | ||
193 | - qemu_irq output_irq[IIC_NGRP]; | ||
194 | -}; | ||
195 | |||
196 | static const VMStateDescription vmstate_exynos4210_combiner_group_state = { | ||
197 | .name = "exynos4210.combiner.groupstate", | ||
198 | -- | 607 | -- |
199 | 2.25.1 | 608 | 2.34.1 |
609 | |||
610 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | 1 | From: Richard Henderson <richard.henderson@linaro.org> |
---|---|---|---|
2 | 2 | ||
3 | Add the Cortex-R5Fs of the Versal RPU (Real-time Processing Unit) | 3 | While the 8-bit input elements are sequential in the input vector, |
4 | subsystem. | 4 | the 32-bit output elements are not sequential in the output matrix. |
5 | 5 | Do not attempt to compute 2 32-bit outputs at the same time. | |
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | 6 | |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | 7 | Cc: qemu-stable@nongnu.org |
8 | Message-id: 20220406174303.2022038-3-edgar.iglesias@xilinx.com | 8 | Fixes: 23a5e3859f5 ("target/arm: Implement SME integer outer product") |
9 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2083 | ||
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
12 | Message-id: 20240305163931.242795-1-richard.henderson@linaro.org | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
10 | --- | 14 | --- |
11 | include/hw/arm/xlnx-versal.h | 10 ++++++++++ | 15 | target/arm/tcg/sme_helper.c | 77 ++++++++++++++++++------------- |
12 | hw/arm/xlnx-versal-virt.c | 6 +++--- | 16 | tests/tcg/aarch64/sme-smopa-1.c | 47 +++++++++++++++++++ |
13 | hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++++++++++ | 17 | tests/tcg/aarch64/sme-smopa-2.c | 54 ++++++++++++++++++++++ |
14 | 3 files changed, 49 insertions(+), 3 deletions(-) | 18 | tests/tcg/aarch64/Makefile.target | 2 +- |
15 | 19 | 4 files changed, 147 insertions(+), 33 deletions(-) | |
16 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | 20 | create mode 100644 tests/tcg/aarch64/sme-smopa-1.c |
21 | create mode 100644 tests/tcg/aarch64/sme-smopa-2.c | ||
22 | |||
23 | diff --git a/target/arm/tcg/sme_helper.c b/target/arm/tcg/sme_helper.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/include/hw/arm/xlnx-versal.h | 25 | --- a/target/arm/tcg/sme_helper.c |
19 | +++ b/include/hw/arm/xlnx-versal.h | 26 | +++ b/target/arm/tcg/sme_helper.c |
20 | @@ -XXX,XX +XXX,XX @@ | 27 | @@ -XXX,XX +XXX,XX @@ void HELPER(sme_bfmopa)(void *vza, void *vzn, void *vzm, void *vpn, |
21 | OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) | ||
22 | |||
23 | #define XLNX_VERSAL_NR_ACPUS 2 | ||
24 | +#define XLNX_VERSAL_NR_RCPUS 2 | ||
25 | #define XLNX_VERSAL_NR_UARTS 2 | ||
26 | #define XLNX_VERSAL_NR_GEMS 2 | ||
27 | #define XLNX_VERSAL_NR_ADMAS 8 | ||
28 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
29 | VersalUsb2 usb; | ||
30 | } iou; | ||
31 | |||
32 | + /* Real-time Processing Unit. */ | ||
33 | + struct { | ||
34 | + MemoryRegion mr; | ||
35 | + MemoryRegion mr_ps_alias; | ||
36 | + | ||
37 | + CPUClusterState cluster; | ||
38 | + ARMCPU cpu[XLNX_VERSAL_NR_RCPUS]; | ||
39 | + } rpu; | ||
40 | + | ||
41 | struct { | ||
42 | qemu_or_irq irq_orgate; | ||
43 | XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; | ||
44 | diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/xlnx-versal-virt.c | ||
47 | +++ b/hw/arm/xlnx-versal-virt.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void versal_virt_machine_class_init(ObjectClass *oc, void *data) | ||
49 | |||
50 | mc->desc = "Xilinx Versal Virtual development board"; | ||
51 | mc->init = versal_virt_init; | ||
52 | - mc->min_cpus = XLNX_VERSAL_NR_ACPUS; | ||
53 | - mc->max_cpus = XLNX_VERSAL_NR_ACPUS; | ||
54 | - mc->default_cpus = XLNX_VERSAL_NR_ACPUS; | ||
55 | + mc->min_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | ||
56 | + mc->max_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | ||
57 | + mc->default_cpus = XLNX_VERSAL_NR_ACPUS + XLNX_VERSAL_NR_RCPUS; | ||
58 | mc->no_cdrom = true; | ||
59 | mc->default_ram_id = "ddr"; | ||
60 | } | ||
61 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
62 | index XXXXXXX..XXXXXXX 100644 | ||
63 | --- a/hw/arm/xlnx-versal.c | ||
64 | +++ b/hw/arm/xlnx-versal.c | ||
65 | @@ -XXX,XX +XXX,XX @@ | ||
66 | #include "hw/sysbus.h" | ||
67 | |||
68 | #define XLNX_VERSAL_ACPU_TYPE ARM_CPU_TYPE_NAME("cortex-a72") | ||
69 | +#define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f") | ||
70 | #define GEM_REVISION 0x40070106 | ||
71 | |||
72 | #define VERSAL_NUM_PMC_APB_IRQS 3 | ||
73 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_gic(Versal *s, qemu_irq *pic) | ||
74 | } | 28 | } |
75 | } | 29 | } |
76 | 30 | ||
77 | +static void versal_create_rpu_cpus(Versal *s) | 31 | -typedef uint64_t IMOPFn(uint64_t, uint64_t, uint64_t, uint8_t, bool); |
32 | +typedef uint32_t IMOPFn32(uint32_t, uint32_t, uint32_t, uint8_t, bool); | ||
33 | +static inline void do_imopa_s(uint32_t *za, uint32_t *zn, uint32_t *zm, | ||
34 | + uint8_t *pn, uint8_t *pm, | ||
35 | + uint32_t desc, IMOPFn32 *fn) | ||
78 | +{ | 36 | +{ |
79 | + int i; | 37 | + intptr_t row, col, oprsz = simd_oprsz(desc) / 4; |
80 | + | 38 | + bool neg = simd_data(desc); |
81 | + object_initialize_child(OBJECT(s), "rpu-cluster", &s->lpd.rpu.cluster, | 39 | |
82 | + TYPE_CPU_CLUSTER); | 40 | -static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, |
83 | + qdev_prop_set_uint32(DEVICE(&s->lpd.rpu.cluster), "cluster-id", 1); | 41 | - uint8_t *pn, uint8_t *pm, |
84 | + | 42 | - uint32_t desc, IMOPFn *fn) |
85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { | 43 | + for (row = 0; row < oprsz; ++row) { |
86 | + Object *obj; | 44 | + uint8_t pa = (pn[H1(row >> 1)] >> ((row & 1) * 4)) & 0xf; |
87 | + | 45 | + uint32_t *za_row = &za[tile_vslice_index(row)]; |
88 | + object_initialize_child(OBJECT(&s->lpd.rpu.cluster), | 46 | + uint32_t n = zn[H4(row)]; |
89 | + "rpu-cpu[*]", &s->lpd.rpu.cpu[i], | 47 | + |
90 | + XLNX_VERSAL_RCPU_TYPE); | 48 | + for (col = 0; col < oprsz; ++col) { |
91 | + obj = OBJECT(&s->lpd.rpu.cpu[i]); | 49 | + uint8_t pb = pm[H1(col >> 1)] >> ((col & 1) * 4); |
92 | + object_property_set_bool(obj, "start-powered-off", true, | 50 | + uint32_t *a = &za_row[H4(col)]; |
93 | + &error_abort); | 51 | + |
94 | + | 52 | + *a = fn(n, zm[H4(col)], *a, pa & pb, neg); |
95 | + object_property_set_int(obj, "mp-affinity", 0x100 | i, &error_abort); | 53 | + } |
96 | + object_property_set_int(obj, "core-count", ARRAY_SIZE(s->lpd.rpu.cpu), | 54 | + } |
97 | + &error_abort); | ||
98 | + object_property_set_link(obj, "memory", OBJECT(&s->lpd.rpu.mr), | ||
99 | + &error_abort); | ||
100 | + qdev_realize(DEVICE(obj), NULL, &error_fatal); | ||
101 | + } | ||
102 | + | ||
103 | + qdev_realize(DEVICE(&s->lpd.rpu.cluster), NULL, &error_fatal); | ||
104 | +} | 55 | +} |
105 | + | 56 | + |
106 | static void versal_create_uarts(Versal *s, qemu_irq *pic) | 57 | +typedef uint64_t IMOPFn64(uint64_t, uint64_t, uint64_t, uint8_t, bool); |
58 | +static inline void do_imopa_d(uint64_t *za, uint64_t *zn, uint64_t *zm, | ||
59 | + uint8_t *pn, uint8_t *pm, | ||
60 | + uint32_t desc, IMOPFn64 *fn) | ||
107 | { | 61 | { |
108 | int i; | 62 | intptr_t row, col, oprsz = simd_oprsz(desc) / 8; |
109 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | 63 | bool neg = simd_data(desc); |
110 | 64 | @@ -XXX,XX +XXX,XX @@ static inline void do_imopa(uint64_t *za, uint64_t *zn, uint64_t *zm, | |
111 | versal_create_apu_cpus(s); | ||
112 | versal_create_apu_gic(s, pic); | ||
113 | + versal_create_rpu_cpus(s); | ||
114 | versal_create_uarts(s, pic); | ||
115 | versal_create_usbs(s, pic); | ||
116 | versal_create_gems(s, pic); | ||
117 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
118 | |||
119 | memory_region_add_subregion_overlap(&s->mr_ps, MM_OCM, &s->lpd.mr_ocm, 0); | ||
120 | memory_region_add_subregion_overlap(&s->fpd.apu.mr, 0, &s->mr_ps, 0); | ||
121 | + memory_region_add_subregion_overlap(&s->lpd.rpu.mr, 0, | ||
122 | + &s->lpd.rpu.mr_ps_alias, 0); | ||
123 | } | 65 | } |
124 | 66 | ||
125 | static void versal_init(Object *obj) | 67 | #define DEF_IMOP_32(NAME, NTYPE, MTYPE) \ |
126 | @@ -XXX,XX +XXX,XX @@ static void versal_init(Object *obj) | 68 | -static uint64_t NAME(uint64_t n, uint64_t m, uint64_t a, uint8_t p, bool neg) \ |
127 | Versal *s = XLNX_VERSAL(obj); | 69 | +static uint32_t NAME(uint32_t n, uint32_t m, uint32_t a, uint8_t p, bool neg) \ |
128 | 70 | { \ | |
129 | memory_region_init(&s->fpd.apu.mr, obj, "mr-apu", UINT64_MAX); | 71 | - uint32_t sum0 = 0, sum1 = 0; \ |
130 | + memory_region_init(&s->lpd.rpu.mr, obj, "mr-rpu", UINT64_MAX); | 72 | + uint32_t sum = 0; \ |
131 | memory_region_init(&s->mr_ps, obj, "mr-ps-switch", UINT64_MAX); | 73 | /* Apply P to N as a mask, making the inactive elements 0. */ \ |
132 | + memory_region_init_alias(&s->lpd.rpu.mr_ps_alias, OBJECT(s), | 74 | n &= expand_pred_b(p); \ |
133 | + "mr-rpu-ps-alias", &s->mr_ps, 0, UINT64_MAX); | 75 | - sum0 += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ |
76 | - sum0 += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
77 | - sum0 += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
78 | - sum0 += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
79 | - sum1 += (NTYPE)(n >> 32) * (MTYPE)(m >> 32); \ | ||
80 | - sum1 += (NTYPE)(n >> 40) * (MTYPE)(m >> 40); \ | ||
81 | - sum1 += (NTYPE)(n >> 48) * (MTYPE)(m >> 48); \ | ||
82 | - sum1 += (NTYPE)(n >> 56) * (MTYPE)(m >> 56); \ | ||
83 | - if (neg) { \ | ||
84 | - sum0 = (uint32_t)a - sum0, sum1 = (uint32_t)(a >> 32) - sum1; \ | ||
85 | - } else { \ | ||
86 | - sum0 = (uint32_t)a + sum0, sum1 = (uint32_t)(a >> 32) + sum1; \ | ||
87 | - } \ | ||
88 | - return ((uint64_t)sum1 << 32) | sum0; \ | ||
89 | + sum += (NTYPE)(n >> 0) * (MTYPE)(m >> 0); \ | ||
90 | + sum += (NTYPE)(n >> 8) * (MTYPE)(m >> 8); \ | ||
91 | + sum += (NTYPE)(n >> 16) * (MTYPE)(m >> 16); \ | ||
92 | + sum += (NTYPE)(n >> 24) * (MTYPE)(m >> 24); \ | ||
93 | + return neg ? a - sum : a + sum; \ | ||
134 | } | 94 | } |
135 | 95 | ||
136 | static Property versal_properties[] = { | 96 | #define DEF_IMOP_64(NAME, NTYPE, MTYPE) \ |
97 | @@ -XXX,XX +XXX,XX @@ DEF_IMOP_64(umopa_d, uint16_t, uint16_t) | ||
98 | DEF_IMOP_64(sumopa_d, int16_t, uint16_t) | ||
99 | DEF_IMOP_64(usmopa_d, uint16_t, int16_t) | ||
100 | |||
101 | -#define DEF_IMOPH(NAME) \ | ||
102 | - void HELPER(sme_##NAME)(void *vza, void *vzn, void *vzm, void *vpn, \ | ||
103 | - void *vpm, uint32_t desc) \ | ||
104 | - { do_imopa(vza, vzn, vzm, vpn, vpm, desc, NAME); } | ||
105 | +#define DEF_IMOPH(NAME, S) \ | ||
106 | + void HELPER(sme_##NAME##_##S)(void *vza, void *vzn, void *vzm, \ | ||
107 | + void *vpn, void *vpm, uint32_t desc) \ | ||
108 | + { do_imopa_##S(vza, vzn, vzm, vpn, vpm, desc, NAME##_##S); } | ||
109 | |||
110 | -DEF_IMOPH(smopa_s) | ||
111 | -DEF_IMOPH(umopa_s) | ||
112 | -DEF_IMOPH(sumopa_s) | ||
113 | -DEF_IMOPH(usmopa_s) | ||
114 | -DEF_IMOPH(smopa_d) | ||
115 | -DEF_IMOPH(umopa_d) | ||
116 | -DEF_IMOPH(sumopa_d) | ||
117 | -DEF_IMOPH(usmopa_d) | ||
118 | +DEF_IMOPH(smopa, s) | ||
119 | +DEF_IMOPH(umopa, s) | ||
120 | +DEF_IMOPH(sumopa, s) | ||
121 | +DEF_IMOPH(usmopa, s) | ||
122 | + | ||
123 | +DEF_IMOPH(smopa, d) | ||
124 | +DEF_IMOPH(umopa, d) | ||
125 | +DEF_IMOPH(sumopa, d) | ||
126 | +DEF_IMOPH(usmopa, d) | ||
127 | diff --git a/tests/tcg/aarch64/sme-smopa-1.c b/tests/tcg/aarch64/sme-smopa-1.c | ||
128 | new file mode 100644 | ||
129 | index XXXXXXX..XXXXXXX | ||
130 | --- /dev/null | ||
131 | +++ b/tests/tcg/aarch64/sme-smopa-1.c | ||
132 | @@ -XXX,XX +XXX,XX @@ | ||
133 | +#include <stdio.h> | ||
134 | +#include <string.h> | ||
135 | + | ||
136 | +int main() | ||
137 | +{ | ||
138 | + static const int cmp[4][4] = { | ||
139 | + { 110, 134, 158, 182 }, | ||
140 | + { 390, 478, 566, 654 }, | ||
141 | + { 670, 822, 974, 1126 }, | ||
142 | + { 950, 1166, 1382, 1598 } | ||
143 | + }; | ||
144 | + int dst[4][4]; | ||
145 | + int *tmp = &dst[0][0]; | ||
146 | + | ||
147 | + asm volatile( | ||
148 | + ".arch armv8-r+sme\n\t" | ||
149 | + "smstart\n\t" | ||
150 | + "index z0.b, #0, #1\n\t" | ||
151 | + "movprfx z1, z0\n\t" | ||
152 | + "add z1.b, z1.b, #16\n\t" | ||
153 | + "ptrue p0.b\n\t" | ||
154 | + "smopa za0.s, p0/m, p0/m, z0.b, z1.b\n\t" | ||
155 | + "ptrue p0.s, vl4\n\t" | ||
156 | + "mov w12, #0\n\t" | ||
157 | + "st1w { za0h.s[w12, #0] }, p0, [%0]\n\t" | ||
158 | + "add %0, %0, #16\n\t" | ||
159 | + "st1w { za0h.s[w12, #1] }, p0, [%0]\n\t" | ||
160 | + "add %0, %0, #16\n\t" | ||
161 | + "st1w { za0h.s[w12, #2] }, p0, [%0]\n\t" | ||
162 | + "add %0, %0, #16\n\t" | ||
163 | + "st1w { za0h.s[w12, #3] }, p0, [%0]\n\t" | ||
164 | + "smstop" | ||
165 | + : "+r"(tmp) : : "memory"); | ||
166 | + | ||
167 | + if (memcmp(cmp, dst, sizeof(dst)) == 0) { | ||
168 | + return 0; | ||
169 | + } | ||
170 | + | ||
171 | + /* See above for correct results. */ | ||
172 | + for (int i = 0; i < 4; ++i) { | ||
173 | + for (int j = 0; j < 4; ++j) { | ||
174 | + printf("%6d", dst[i][j]); | ||
175 | + } | ||
176 | + printf("\n"); | ||
177 | + } | ||
178 | + return 1; | ||
179 | +} | ||
180 | diff --git a/tests/tcg/aarch64/sme-smopa-2.c b/tests/tcg/aarch64/sme-smopa-2.c | ||
181 | new file mode 100644 | ||
182 | index XXXXXXX..XXXXXXX | ||
183 | --- /dev/null | ||
184 | +++ b/tests/tcg/aarch64/sme-smopa-2.c | ||
185 | @@ -XXX,XX +XXX,XX @@ | ||
186 | +#include <stdio.h> | ||
187 | +#include <string.h> | ||
188 | + | ||
189 | +int main() | ||
190 | +{ | ||
191 | + static const long cmp[4][4] = { | ||
192 | + { 110, 134, 158, 182 }, | ||
193 | + { 390, 478, 566, 654 }, | ||
194 | + { 670, 822, 974, 1126 }, | ||
195 | + { 950, 1166, 1382, 1598 } | ||
196 | + }; | ||
197 | + long dst[4][4]; | ||
198 | + long *tmp = &dst[0][0]; | ||
199 | + long svl; | ||
200 | + | ||
201 | + /* Validate that we have a wide enough vector for 4 elements. */ | ||
202 | + asm(".arch armv8-r+sme-i64\n\trdsvl %0, #1" : "=r"(svl)); | ||
203 | + if (svl < 32) { | ||
204 | + return 0; | ||
205 | + } | ||
206 | + | ||
207 | + asm volatile( | ||
208 | + "smstart\n\t" | ||
209 | + "index z0.h, #0, #1\n\t" | ||
210 | + "movprfx z1, z0\n\t" | ||
211 | + "add z1.h, z1.h, #16\n\t" | ||
212 | + "ptrue p0.b\n\t" | ||
213 | + "smopa za0.d, p0/m, p0/m, z0.h, z1.h\n\t" | ||
214 | + "ptrue p0.d, vl4\n\t" | ||
215 | + "mov w12, #0\n\t" | ||
216 | + "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t" | ||
217 | + "add %0, %0, #32\n\t" | ||
218 | + "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t" | ||
219 | + "mov w12, #2\n\t" | ||
220 | + "add %0, %0, #32\n\t" | ||
221 | + "st1d { za0h.d[w12, #0] }, p0, [%0]\n\t" | ||
222 | + "add %0, %0, #32\n\t" | ||
223 | + "st1d { za0h.d[w12, #1] }, p0, [%0]\n\t" | ||
224 | + "smstop" | ||
225 | + : "+r"(tmp) : : "memory"); | ||
226 | + | ||
227 | + if (memcmp(cmp, dst, sizeof(dst)) == 0) { | ||
228 | + return 0; | ||
229 | + } | ||
230 | + | ||
231 | + /* See above for correct results. */ | ||
232 | + for (int i = 0; i < 4; ++i) { | ||
233 | + for (int j = 0; j < 4; ++j) { | ||
234 | + printf("%6ld", dst[i][j]); | ||
235 | + } | ||
236 | + printf("\n"); | ||
237 | + } | ||
238 | + return 1; | ||
239 | +} | ||
240 | diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target | ||
241 | index XXXXXXX..XXXXXXX 100644 | ||
242 | --- a/tests/tcg/aarch64/Makefile.target | ||
243 | +++ b/tests/tcg/aarch64/Makefile.target | ||
244 | @@ -XXX,XX +XXX,XX @@ endif | ||
245 | |||
246 | # SME Tests | ||
247 | ifneq ($(CROSS_AS_HAS_ARMV9_SME),) | ||
248 | -AARCH64_TESTS += sme-outprod1 | ||
249 | +AARCH64_TESTS += sme-outprod1 sme-smopa-1 sme-smopa-2 | ||
250 | endif | ||
251 | |||
252 | # System Registers Tests | ||
137 | -- | 253 | -- |
138 | 2.25.1 | 254 | 2.34.1 |
255 | |||
256 | diff view generated by jsdifflib |
1 | From: Hao Wu <wuhaotsh@google.com> | 1 | The sun4v RTC device model added under commit a0e893039cf2ce0 in 2016 |
---|---|---|---|
2 | was unfortunately added with a license of GPL-v3-or-later, which is | ||
3 | not compatible with other QEMU code which has a GPL-v2-only license. | ||
2 | 4 | ||
3 | This patch uses the defined fields to describe PWRON STRAPs for | 5 | Relicense the code in the .c and the .h file to GPL-v2-or-later, |
4 | better readability. | 6 | to make it compatible with the rest of QEMU. |
5 | 7 | ||
6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | 8 | Cc: qemu-stable@nongnu.org |
7 | Reviewed-by: Patrick Venture <venture@google.com> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Message-id: 20220411165842.3912945-3-wuhaotsh@google.com | 10 | Signed-off-by: Paolo Bonzini (for Red Hat) <pbonzini@redhat.com> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 11 | Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> |
12 | Signed-off-by: Markus Armbruster <armbru@redhat.com> | ||
13 | Signed-off-by: Alex Bennée <alex.bennee@linaro.org> | ||
14 | Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> | ||
15 | Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> | ||
16 | Acked-by: Alex Bennée <alex.bennee@linaro.org> | ||
17 | Message-id: 20240223161300.938542-1-peter.maydell@linaro.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 19 | --- |
12 | hw/arm/npcm7xx_boards.c | 24 +++++++++++++++++++----- | 20 | include/hw/rtc/sun4v-rtc.h | 2 +- |
13 | 1 file changed, 19 insertions(+), 5 deletions(-) | 21 | hw/rtc/sun4v-rtc.c | 2 +- |
22 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
14 | 23 | ||
15 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c | 24 | diff --git a/include/hw/rtc/sun4v-rtc.h b/include/hw/rtc/sun4v-rtc.h |
16 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/hw/arm/npcm7xx_boards.c | 26 | --- a/include/hw/rtc/sun4v-rtc.h |
18 | +++ b/hw/arm/npcm7xx_boards.c | 27 | +++ b/include/hw/rtc/sun4v-rtc.h |
19 | @@ -XXX,XX +XXX,XX @@ | 28 | @@ -XXX,XX +XXX,XX @@ |
20 | #include "sysemu/sysemu.h" | 29 | * |
21 | #include "sysemu/block-backend.h" | 30 | * Copyright (c) 2016 Artyom Tarasenko |
22 | 31 | * | |
23 | -#define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7 | 32 | - * This code is licensed under the GNU GPL v3 or (at your option) any later |
24 | -#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff | 33 | + * This code is licensed under the GNU GPL v2 or (at your option) any later |
25 | -#define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff | 34 | * version. |
26 | -#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff | 35 | */ |
27 | -#define MORI_BMC_POWER_ON_STRAPS 0x00001fff | 36 | |
28 | +#define NPCM7XX_POWER_ON_STRAPS_DEFAULT ( \ | 37 | diff --git a/hw/rtc/sun4v-rtc.c b/hw/rtc/sun4v-rtc.c |
29 | + NPCM7XX_PWRON_STRAP_SPI0F18 | \ | 38 | index XXXXXXX..XXXXXXX 100644 |
30 | + NPCM7XX_PWRON_STRAP_SFAB | \ | 39 | --- a/hw/rtc/sun4v-rtc.c |
31 | + NPCM7XX_PWRON_STRAP_BSPA | \ | 40 | +++ b/hw/rtc/sun4v-rtc.c |
32 | + NPCM7XX_PWRON_STRAP_FUP(FUP_NORM_UART2) | \ | 41 | @@ -XXX,XX +XXX,XX @@ |
33 | + NPCM7XX_PWRON_STRAP_SECEN | \ | 42 | * |
34 | + NPCM7XX_PWRON_STRAP_HIZ | \ | 43 | * Copyright (c) 2016 Artyom Tarasenko |
35 | + NPCM7XX_PWRON_STRAP_ECC | \ | 44 | * |
36 | + NPCM7XX_PWRON_STRAP_RESERVE1 | \ | 45 | - * This code is licensed under the GNU GPL v3 or (at your option) any later |
37 | + NPCM7XX_PWRON_STRAP_J2EN | \ | 46 | + * This code is licensed under the GNU GPL v2 or (at your option) any later |
38 | + NPCM7XX_PWRON_STRAP_CKFRQ(CKFRQ_DEFAULT)) | 47 | * version. |
39 | + | 48 | */ |
40 | +#define NPCM750_EVB_POWER_ON_STRAPS ( \ | ||
41 | + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_J2EN) | ||
42 | +#define QUANTA_GSJ_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT | ||
43 | +#define QUANTA_GBS_POWER_ON_STRAPS ( \ | ||
44 | + NPCM7XX_POWER_ON_STRAPS_DEFAULT & ~NPCM7XX_PWRON_STRAP_SFAB) | ||
45 | +#define KUDO_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT | ||
46 | +#define MORI_BMC_POWER_ON_STRAPS NPCM7XX_POWER_ON_STRAPS_DEFAULT | ||
47 | |||
48 | static const char npcm7xx_default_bootrom[] = "npcm7xx_bootrom.bin"; | ||
49 | 49 | ||
50 | -- | 50 | -- |
51 | 2.25.1 | 51 | 2.34.1 |
52 | |||
53 | diff view generated by jsdifflib |
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | 1 | From: Thomas Huth <thuth@redhat.com> |
---|---|---|---|
2 | 2 | ||
3 | Break out header file to allow embedding of the the TTC. | 3 | Move the code to a separate file so that we do not have to compile |
4 | it anymore if CONFIG_ARM_V7M is not set. | ||
4 | 5 | ||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | 6 | Signed-off-by: Thomas Huth <thuth@redhat.com> |
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | 7 | Message-id: 20240308141051.536599-2-thuth@redhat.com |
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
9 | Message-id: 20220331222017.2914409-2-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
11 | --- | 10 | --- |
12 | include/hw/timer/cadence_ttc.h | 54 ++++++++++++++++++++++++++++++++++ | 11 | target/arm/tcg/cpu-v7m.c | 290 +++++++++++++++++++++++++++++++++++++ |
13 | hw/timer/cadence_ttc.c | 32 ++------------------ | 12 | target/arm/tcg/cpu32.c | 261 --------------------------------- |
14 | 2 files changed, 56 insertions(+), 30 deletions(-) | 13 | target/arm/meson.build | 3 + |
15 | create mode 100644 include/hw/timer/cadence_ttc.h | 14 | target/arm/tcg/meson.build | 3 + |
15 | 4 files changed, 296 insertions(+), 261 deletions(-) | ||
16 | create mode 100644 target/arm/tcg/cpu-v7m.c | ||
16 | 17 | ||
17 | diff --git a/include/hw/timer/cadence_ttc.h b/include/hw/timer/cadence_ttc.h | 18 | diff --git a/target/arm/tcg/cpu-v7m.c b/target/arm/tcg/cpu-v7m.c |
18 | new file mode 100644 | 19 | new file mode 100644 |
19 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
20 | --- /dev/null | 21 | --- /dev/null |
21 | +++ b/include/hw/timer/cadence_ttc.h | 22 | +++ b/target/arm/tcg/cpu-v7m.c |
22 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
23 | +/* | 24 | +/* |
24 | + * Xilinx Zynq cadence TTC model | 25 | + * QEMU ARMv7-M TCG-only CPUs. |
25 | + * | 26 | + * |
26 | + * Copyright (c) 2011 Xilinx Inc. | 27 | + * Copyright (c) 2012 SUSE LINUX Products GmbH |
27 | + * Copyright (c) 2012 Peter A.G. Crosthwaite (peter.crosthwaite@petalogix.com) | ||
28 | + * Copyright (c) 2012 PetaLogix Pty Ltd. | ||
29 | + * Written By Haibing Ma | ||
30 | + * M. Habib | ||
31 | + * | 28 | + * |
32 | + * This program is free software; you can redistribute it and/or | 29 | + * This code is licensed under the GNU GPL v2 or later. |
33 | + * modify it under the terms of the GNU General Public License | ||
34 | + * as published by the Free Software Foundation; either version | ||
35 | + * 2 of the License, or (at your option) any later version. | ||
36 | + * | 30 | + * |
37 | + * You should have received a copy of the GNU General Public License along | 31 | + * SPDX-License-Identifier: GPL-2.0-or-later |
38 | + * with this program; if not, see <http://www.gnu.org/licenses/>. | ||
39 | + */ | 32 | + */ |
40 | +#ifndef HW_TIMER_CADENCE_TTC_H | 33 | + |
41 | +#define HW_TIMER_CADENCE_TTC_H | 34 | +#include "qemu/osdep.h" |
42 | + | 35 | +#include "cpu.h" |
43 | +#include "hw/sysbus.h" | 36 | +#include "hw/core/tcg-cpu-ops.h" |
44 | +#include "qemu/timer.h" | 37 | +#include "internals.h" |
45 | + | 38 | + |
46 | +typedef struct { | 39 | +#if !defined(CONFIG_USER_ONLY) |
47 | + QEMUTimer *timer; | 40 | + |
48 | + int freq; | 41 | +#include "hw/intc/armv7m_nvic.h" |
49 | + | 42 | + |
50 | + uint32_t reg_clock; | 43 | +static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) |
51 | + uint32_t reg_count; | 44 | +{ |
52 | + uint32_t reg_value; | 45 | + CPUClass *cc = CPU_GET_CLASS(cs); |
53 | + uint16_t reg_interval; | 46 | + ARMCPU *cpu = ARM_CPU(cs); |
54 | + uint16_t reg_match[3]; | 47 | + CPUARMState *env = &cpu->env; |
55 | + uint32_t reg_intr; | 48 | + bool ret = false; |
56 | + uint32_t reg_intr_en; | 49 | + |
57 | + uint32_t reg_event_ctrl; | 50 | + /* |
58 | + uint32_t reg_event; | 51 | + * ARMv7-M interrupt masking works differently than -A or -R. |
59 | + | 52 | + * There is no FIQ/IRQ distinction. Instead of I and F bits |
60 | + uint64_t cpu_time; | 53 | + * masking FIQ and IRQ interrupts, an exception is taken only |
61 | + unsigned int cpu_time_valid; | 54 | + * if it is higher priority than the current execution priority |
62 | + | 55 | + * (which depends on state like BASEPRI, FAULTMASK and the |
63 | + qemu_irq irq; | 56 | + * currently active exception). |
64 | +} CadenceTimerState; | 57 | + */ |
65 | + | 58 | + if (interrupt_request & CPU_INTERRUPT_HARD |
66 | +#define TYPE_CADENCE_TTC "cadence_ttc" | 59 | + && (armv7m_nvic_can_take_pending_exception(env->nvic))) { |
67 | +OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC) | 60 | + cs->exception_index = EXCP_IRQ; |
68 | + | 61 | + cc->tcg_ops->do_interrupt(cs); |
69 | +struct CadenceTTCState { | 62 | + ret = true; |
70 | + SysBusDevice parent_obj; | 63 | + } |
71 | + | 64 | + return ret; |
72 | + MemoryRegion iomem; | 65 | +} |
73 | + CadenceTimerState timer[3]; | 66 | + |
67 | +#endif /* !CONFIG_USER_ONLY */ | ||
68 | + | ||
69 | +static void cortex_m0_initfn(Object *obj) | ||
70 | +{ | ||
71 | + ARMCPU *cpu = ARM_CPU(obj); | ||
72 | + set_feature(&cpu->env, ARM_FEATURE_V6); | ||
73 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
74 | + | ||
75 | + cpu->midr = 0x410cc200; | ||
76 | + | ||
77 | + /* | ||
78 | + * These ID register values are not guest visible, because | ||
79 | + * we do not implement the Main Extension. They must be set | ||
80 | + * to values corresponding to the Cortex-M0's implemented | ||
81 | + * features, because QEMU generally controls its emulation | ||
82 | + * by looking at ID register fields. We use the same values as | ||
83 | + * for the M3. | ||
84 | + */ | ||
85 | + cpu->isar.id_pfr0 = 0x00000030; | ||
86 | + cpu->isar.id_pfr1 = 0x00000200; | ||
87 | + cpu->isar.id_dfr0 = 0x00100000; | ||
88 | + cpu->id_afr0 = 0x00000000; | ||
89 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
90 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
91 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
92 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
93 | + cpu->isar.id_isar0 = 0x01141110; | ||
94 | + cpu->isar.id_isar1 = 0x02111000; | ||
95 | + cpu->isar.id_isar2 = 0x21112231; | ||
96 | + cpu->isar.id_isar3 = 0x01111110; | ||
97 | + cpu->isar.id_isar4 = 0x01310102; | ||
98 | + cpu->isar.id_isar5 = 0x00000000; | ||
99 | + cpu->isar.id_isar6 = 0x00000000; | ||
100 | +} | ||
101 | + | ||
102 | +static void cortex_m3_initfn(Object *obj) | ||
103 | +{ | ||
104 | + ARMCPU *cpu = ARM_CPU(obj); | ||
105 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
106 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
107 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
108 | + cpu->midr = 0x410fc231; | ||
109 | + cpu->pmsav7_dregion = 8; | ||
110 | + cpu->isar.id_pfr0 = 0x00000030; | ||
111 | + cpu->isar.id_pfr1 = 0x00000200; | ||
112 | + cpu->isar.id_dfr0 = 0x00100000; | ||
113 | + cpu->id_afr0 = 0x00000000; | ||
114 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
115 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
116 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
117 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
118 | + cpu->isar.id_isar0 = 0x01141110; | ||
119 | + cpu->isar.id_isar1 = 0x02111000; | ||
120 | + cpu->isar.id_isar2 = 0x21112231; | ||
121 | + cpu->isar.id_isar3 = 0x01111110; | ||
122 | + cpu->isar.id_isar4 = 0x01310102; | ||
123 | + cpu->isar.id_isar5 = 0x00000000; | ||
124 | + cpu->isar.id_isar6 = 0x00000000; | ||
125 | +} | ||
126 | + | ||
127 | +static void cortex_m4_initfn(Object *obj) | ||
128 | +{ | ||
129 | + ARMCPU *cpu = ARM_CPU(obj); | ||
130 | + | ||
131 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
132 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
133 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
134 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
135 | + cpu->midr = 0x410fc240; /* r0p0 */ | ||
136 | + cpu->pmsav7_dregion = 8; | ||
137 | + cpu->isar.mvfr0 = 0x10110021; | ||
138 | + cpu->isar.mvfr1 = 0x11000011; | ||
139 | + cpu->isar.mvfr2 = 0x00000000; | ||
140 | + cpu->isar.id_pfr0 = 0x00000030; | ||
141 | + cpu->isar.id_pfr1 = 0x00000200; | ||
142 | + cpu->isar.id_dfr0 = 0x00100000; | ||
143 | + cpu->id_afr0 = 0x00000000; | ||
144 | + cpu->isar.id_mmfr0 = 0x00000030; | ||
145 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
146 | + cpu->isar.id_mmfr2 = 0x00000000; | ||
147 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
148 | + cpu->isar.id_isar0 = 0x01141110; | ||
149 | + cpu->isar.id_isar1 = 0x02111000; | ||
150 | + cpu->isar.id_isar2 = 0x21112231; | ||
151 | + cpu->isar.id_isar3 = 0x01111110; | ||
152 | + cpu->isar.id_isar4 = 0x01310102; | ||
153 | + cpu->isar.id_isar5 = 0x00000000; | ||
154 | + cpu->isar.id_isar6 = 0x00000000; | ||
155 | +} | ||
156 | + | ||
157 | +static void cortex_m7_initfn(Object *obj) | ||
158 | +{ | ||
159 | + ARMCPU *cpu = ARM_CPU(obj); | ||
160 | + | ||
161 | + set_feature(&cpu->env, ARM_FEATURE_V7); | ||
162 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
163 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
164 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
165 | + cpu->midr = 0x411fc272; /* r1p2 */ | ||
166 | + cpu->pmsav7_dregion = 8; | ||
167 | + cpu->isar.mvfr0 = 0x10110221; | ||
168 | + cpu->isar.mvfr1 = 0x12000011; | ||
169 | + cpu->isar.mvfr2 = 0x00000040; | ||
170 | + cpu->isar.id_pfr0 = 0x00000030; | ||
171 | + cpu->isar.id_pfr1 = 0x00000200; | ||
172 | + cpu->isar.id_dfr0 = 0x00100000; | ||
173 | + cpu->id_afr0 = 0x00000000; | ||
174 | + cpu->isar.id_mmfr0 = 0x00100030; | ||
175 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
176 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
177 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
178 | + cpu->isar.id_isar0 = 0x01101110; | ||
179 | + cpu->isar.id_isar1 = 0x02112000; | ||
180 | + cpu->isar.id_isar2 = 0x20232231; | ||
181 | + cpu->isar.id_isar3 = 0x01111131; | ||
182 | + cpu->isar.id_isar4 = 0x01310132; | ||
183 | + cpu->isar.id_isar5 = 0x00000000; | ||
184 | + cpu->isar.id_isar6 = 0x00000000; | ||
185 | +} | ||
186 | + | ||
187 | +static void cortex_m33_initfn(Object *obj) | ||
188 | +{ | ||
189 | + ARMCPU *cpu = ARM_CPU(obj); | ||
190 | + | ||
191 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
192 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
193 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
194 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
195 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
196 | + cpu->midr = 0x410fd213; /* r0p3 */ | ||
197 | + cpu->pmsav7_dregion = 16; | ||
198 | + cpu->sau_sregion = 8; | ||
199 | + cpu->isar.mvfr0 = 0x10110021; | ||
200 | + cpu->isar.mvfr1 = 0x11000011; | ||
201 | + cpu->isar.mvfr2 = 0x00000040; | ||
202 | + cpu->isar.id_pfr0 = 0x00000030; | ||
203 | + cpu->isar.id_pfr1 = 0x00000210; | ||
204 | + cpu->isar.id_dfr0 = 0x00200000; | ||
205 | + cpu->id_afr0 = 0x00000000; | ||
206 | + cpu->isar.id_mmfr0 = 0x00101F40; | ||
207 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
208 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
209 | + cpu->isar.id_mmfr3 = 0x00000000; | ||
210 | + cpu->isar.id_isar0 = 0x01101110; | ||
211 | + cpu->isar.id_isar1 = 0x02212000; | ||
212 | + cpu->isar.id_isar2 = 0x20232232; | ||
213 | + cpu->isar.id_isar3 = 0x01111131; | ||
214 | + cpu->isar.id_isar4 = 0x01310132; | ||
215 | + cpu->isar.id_isar5 = 0x00000000; | ||
216 | + cpu->isar.id_isar6 = 0x00000000; | ||
217 | + cpu->clidr = 0x00000000; | ||
218 | + cpu->ctr = 0x8000c000; | ||
219 | +} | ||
220 | + | ||
221 | +static void cortex_m55_initfn(Object *obj) | ||
222 | +{ | ||
223 | + ARMCPU *cpu = ARM_CPU(obj); | ||
224 | + | ||
225 | + set_feature(&cpu->env, ARM_FEATURE_V8); | ||
226 | + set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
227 | + set_feature(&cpu->env, ARM_FEATURE_M); | ||
228 | + set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
229 | + set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
230 | + set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
231 | + cpu->midr = 0x410fd221; /* r0p1 */ | ||
232 | + cpu->revidr = 0; | ||
233 | + cpu->pmsav7_dregion = 16; | ||
234 | + cpu->sau_sregion = 8; | ||
235 | + /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
236 | + cpu->isar.mvfr0 = 0x10110221; | ||
237 | + cpu->isar.mvfr1 = 0x12100211; | ||
238 | + cpu->isar.mvfr2 = 0x00000040; | ||
239 | + cpu->isar.id_pfr0 = 0x20000030; | ||
240 | + cpu->isar.id_pfr1 = 0x00000230; | ||
241 | + cpu->isar.id_dfr0 = 0x10200000; | ||
242 | + cpu->id_afr0 = 0x00000000; | ||
243 | + cpu->isar.id_mmfr0 = 0x00111040; | ||
244 | + cpu->isar.id_mmfr1 = 0x00000000; | ||
245 | + cpu->isar.id_mmfr2 = 0x01000000; | ||
246 | + cpu->isar.id_mmfr3 = 0x00000011; | ||
247 | + cpu->isar.id_isar0 = 0x01103110; | ||
248 | + cpu->isar.id_isar1 = 0x02212000; | ||
249 | + cpu->isar.id_isar2 = 0x20232232; | ||
250 | + cpu->isar.id_isar3 = 0x01111131; | ||
251 | + cpu->isar.id_isar4 = 0x01310132; | ||
252 | + cpu->isar.id_isar5 = 0x00000000; | ||
253 | + cpu->isar.id_isar6 = 0x00000000; | ||
254 | + cpu->clidr = 0x00000000; /* caches not implemented */ | ||
255 | + cpu->ctr = 0x8303c003; | ||
256 | +} | ||
257 | + | ||
258 | +static const TCGCPUOps arm_v7m_tcg_ops = { | ||
259 | + .initialize = arm_translate_init, | ||
260 | + .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
261 | + .debug_excp_handler = arm_debug_excp_handler, | ||
262 | + .restore_state_to_opc = arm_restore_state_to_opc, | ||
263 | + | ||
264 | +#ifdef CONFIG_USER_ONLY | ||
265 | + .record_sigsegv = arm_cpu_record_sigsegv, | ||
266 | + .record_sigbus = arm_cpu_record_sigbus, | ||
267 | +#else | ||
268 | + .tlb_fill = arm_cpu_tlb_fill, | ||
269 | + .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, | ||
270 | + .do_interrupt = arm_v7m_cpu_do_interrupt, | ||
271 | + .do_transaction_failed = arm_cpu_do_transaction_failed, | ||
272 | + .do_unaligned_access = arm_cpu_do_unaligned_access, | ||
273 | + .adjust_watchpoint_address = arm_adjust_watchpoint_address, | ||
274 | + .debug_check_watchpoint = arm_debug_check_watchpoint, | ||
275 | + .debug_check_breakpoint = arm_debug_check_breakpoint, | ||
276 | +#endif /* !CONFIG_USER_ONLY */ | ||
74 | +}; | 277 | +}; |
75 | + | 278 | + |
76 | +#endif | 279 | +static void arm_v7m_class_init(ObjectClass *oc, void *data) |
77 | diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c | 280 | +{ |
281 | + ARMCPUClass *acc = ARM_CPU_CLASS(oc); | ||
282 | + CPUClass *cc = CPU_CLASS(oc); | ||
283 | + | ||
284 | + acc->info = data; | ||
285 | + cc->tcg_ops = &arm_v7m_tcg_ops; | ||
286 | + cc->gdb_core_xml_file = "arm-m-profile.xml"; | ||
287 | +} | ||
288 | + | ||
289 | +static const ARMCPUInfo arm_v7m_cpus[] = { | ||
290 | + { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
291 | + .class_init = arm_v7m_class_init }, | ||
292 | + { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
293 | + .class_init = arm_v7m_class_init }, | ||
294 | + { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
295 | + .class_init = arm_v7m_class_init }, | ||
296 | + { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
297 | + .class_init = arm_v7m_class_init }, | ||
298 | + { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
299 | + .class_init = arm_v7m_class_init }, | ||
300 | + { .name = "cortex-m55", .initfn = cortex_m55_initfn, | ||
301 | + .class_init = arm_v7m_class_init }, | ||
302 | +}; | ||
303 | + | ||
304 | +static void arm_v7m_cpu_register_types(void) | ||
305 | +{ | ||
306 | + size_t i; | ||
307 | + | ||
308 | + for (i = 0; i < ARRAY_SIZE(arm_v7m_cpus); ++i) { | ||
309 | + arm_cpu_register(&arm_v7m_cpus[i]); | ||
310 | + } | ||
311 | +} | ||
312 | + | ||
313 | +type_init(arm_v7m_cpu_register_types) | ||
314 | diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | 315 | index XXXXXXX..XXXXXXX 100644 |
79 | --- a/hw/timer/cadence_ttc.c | 316 | --- a/target/arm/tcg/cpu32.c |
80 | +++ b/hw/timer/cadence_ttc.c | 317 | +++ b/target/arm/tcg/cpu32.c |
81 | @@ -XXX,XX +XXX,XX @@ | 318 | @@ -XXX,XX +XXX,XX @@ |
82 | #include "qemu/timer.h" | 319 | #include "hw/boards.h" |
83 | #include "qom/object.h" | 320 | #endif |
84 | 321 | #include "cpregs.h" | |
85 | +#include "hw/timer/cadence_ttc.h" | 322 | -#if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) |
86 | + | 323 | -#include "hw/intc/armv7m_nvic.h" |
87 | #ifdef CADENCE_TTC_ERR_DEBUG | 324 | -#endif |
88 | #define DB_PRINT(...) do { \ | 325 | |
89 | fprintf(stderr, ": %s: ", __func__); \ | 326 | |
90 | @@ -XXX,XX +XXX,XX @@ | 327 | /* Share AArch32 -cpu max features with AArch64. */ |
91 | #define CLOCK_CTRL_PS_EN 0x00000001 | 328 | @@ -XXX,XX +XXX,XX @@ void aa32_max_features(ARMCPU *cpu) |
92 | #define CLOCK_CTRL_PS_V 0x0000001e | 329 | /* CPU models. These are not needed for the AArch64 linux-user build. */ |
93 | 330 | #if !defined(CONFIG_USER_ONLY) || !defined(TARGET_AARCH64) | |
94 | -typedef struct { | 331 | |
95 | - QEMUTimer *timer; | 332 | -#if !defined(CONFIG_USER_ONLY) |
96 | - int freq; | 333 | -static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) |
97 | - | 334 | -{ |
98 | - uint32_t reg_clock; | 335 | - CPUClass *cc = CPU_GET_CLASS(cs); |
99 | - uint32_t reg_count; | 336 | - ARMCPU *cpu = ARM_CPU(cs); |
100 | - uint32_t reg_value; | 337 | - CPUARMState *env = &cpu->env; |
101 | - uint16_t reg_interval; | 338 | - bool ret = false; |
102 | - uint16_t reg_match[3]; | 339 | - |
103 | - uint32_t reg_intr; | 340 | - /* |
104 | - uint32_t reg_intr_en; | 341 | - * ARMv7-M interrupt masking works differently than -A or -R. |
105 | - uint32_t reg_event_ctrl; | 342 | - * There is no FIQ/IRQ distinction. Instead of I and F bits |
106 | - uint32_t reg_event; | 343 | - * masking FIQ and IRQ interrupts, an exception is taken only |
107 | - | 344 | - * if it is higher priority than the current execution priority |
108 | - uint64_t cpu_time; | 345 | - * (which depends on state like BASEPRI, FAULTMASK and the |
109 | - unsigned int cpu_time_valid; | 346 | - * currently active exception). |
110 | - | 347 | - */ |
111 | - qemu_irq irq; | 348 | - if (interrupt_request & CPU_INTERRUPT_HARD |
112 | -} CadenceTimerState; | 349 | - && (armv7m_nvic_can_take_pending_exception(env->nvic))) { |
113 | - | 350 | - cs->exception_index = EXCP_IRQ; |
114 | -#define TYPE_CADENCE_TTC "cadence_ttc" | 351 | - cc->tcg_ops->do_interrupt(cs); |
115 | -OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC) | 352 | - ret = true; |
116 | - | 353 | - } |
117 | -struct CadenceTTCState { | 354 | - return ret; |
118 | - SysBusDevice parent_obj; | 355 | -} |
119 | - | 356 | -#endif /* !CONFIG_USER_ONLY */ |
120 | - MemoryRegion iomem; | 357 | - |
121 | - CadenceTimerState timer[3]; | 358 | static void arm926_initfn(Object *obj) |
359 | { | ||
360 | ARMCPU *cpu = ARM_CPU(obj); | ||
361 | @@ -XXX,XX +XXX,XX @@ static void cortex_a15_initfn(Object *obj) | ||
362 | define_arm_cp_regs(cpu, cortexa15_cp_reginfo); | ||
363 | } | ||
364 | |||
365 | -static void cortex_m0_initfn(Object *obj) | ||
366 | -{ | ||
367 | - ARMCPU *cpu = ARM_CPU(obj); | ||
368 | - set_feature(&cpu->env, ARM_FEATURE_V6); | ||
369 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
370 | - | ||
371 | - cpu->midr = 0x410cc200; | ||
372 | - | ||
373 | - /* | ||
374 | - * These ID register values are not guest visible, because | ||
375 | - * we do not implement the Main Extension. They must be set | ||
376 | - * to values corresponding to the Cortex-M0's implemented | ||
377 | - * features, because QEMU generally controls its emulation | ||
378 | - * by looking at ID register fields. We use the same values as | ||
379 | - * for the M3. | ||
380 | - */ | ||
381 | - cpu->isar.id_pfr0 = 0x00000030; | ||
382 | - cpu->isar.id_pfr1 = 0x00000200; | ||
383 | - cpu->isar.id_dfr0 = 0x00100000; | ||
384 | - cpu->id_afr0 = 0x00000000; | ||
385 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
386 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
387 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
388 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
389 | - cpu->isar.id_isar0 = 0x01141110; | ||
390 | - cpu->isar.id_isar1 = 0x02111000; | ||
391 | - cpu->isar.id_isar2 = 0x21112231; | ||
392 | - cpu->isar.id_isar3 = 0x01111110; | ||
393 | - cpu->isar.id_isar4 = 0x01310102; | ||
394 | - cpu->isar.id_isar5 = 0x00000000; | ||
395 | - cpu->isar.id_isar6 = 0x00000000; | ||
396 | -} | ||
397 | - | ||
398 | -static void cortex_m3_initfn(Object *obj) | ||
399 | -{ | ||
400 | - ARMCPU *cpu = ARM_CPU(obj); | ||
401 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
402 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
403 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
404 | - cpu->midr = 0x410fc231; | ||
405 | - cpu->pmsav7_dregion = 8; | ||
406 | - cpu->isar.id_pfr0 = 0x00000030; | ||
407 | - cpu->isar.id_pfr1 = 0x00000200; | ||
408 | - cpu->isar.id_dfr0 = 0x00100000; | ||
409 | - cpu->id_afr0 = 0x00000000; | ||
410 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
411 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
412 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
413 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
414 | - cpu->isar.id_isar0 = 0x01141110; | ||
415 | - cpu->isar.id_isar1 = 0x02111000; | ||
416 | - cpu->isar.id_isar2 = 0x21112231; | ||
417 | - cpu->isar.id_isar3 = 0x01111110; | ||
418 | - cpu->isar.id_isar4 = 0x01310102; | ||
419 | - cpu->isar.id_isar5 = 0x00000000; | ||
420 | - cpu->isar.id_isar6 = 0x00000000; | ||
421 | -} | ||
422 | - | ||
423 | -static void cortex_m4_initfn(Object *obj) | ||
424 | -{ | ||
425 | - ARMCPU *cpu = ARM_CPU(obj); | ||
426 | - | ||
427 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
428 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
429 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
430 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
431 | - cpu->midr = 0x410fc240; /* r0p0 */ | ||
432 | - cpu->pmsav7_dregion = 8; | ||
433 | - cpu->isar.mvfr0 = 0x10110021; | ||
434 | - cpu->isar.mvfr1 = 0x11000011; | ||
435 | - cpu->isar.mvfr2 = 0x00000000; | ||
436 | - cpu->isar.id_pfr0 = 0x00000030; | ||
437 | - cpu->isar.id_pfr1 = 0x00000200; | ||
438 | - cpu->isar.id_dfr0 = 0x00100000; | ||
439 | - cpu->id_afr0 = 0x00000000; | ||
440 | - cpu->isar.id_mmfr0 = 0x00000030; | ||
441 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
442 | - cpu->isar.id_mmfr2 = 0x00000000; | ||
443 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
444 | - cpu->isar.id_isar0 = 0x01141110; | ||
445 | - cpu->isar.id_isar1 = 0x02111000; | ||
446 | - cpu->isar.id_isar2 = 0x21112231; | ||
447 | - cpu->isar.id_isar3 = 0x01111110; | ||
448 | - cpu->isar.id_isar4 = 0x01310102; | ||
449 | - cpu->isar.id_isar5 = 0x00000000; | ||
450 | - cpu->isar.id_isar6 = 0x00000000; | ||
451 | -} | ||
452 | - | ||
453 | -static void cortex_m7_initfn(Object *obj) | ||
454 | -{ | ||
455 | - ARMCPU *cpu = ARM_CPU(obj); | ||
456 | - | ||
457 | - set_feature(&cpu->env, ARM_FEATURE_V7); | ||
458 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
459 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
460 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
461 | - cpu->midr = 0x411fc272; /* r1p2 */ | ||
462 | - cpu->pmsav7_dregion = 8; | ||
463 | - cpu->isar.mvfr0 = 0x10110221; | ||
464 | - cpu->isar.mvfr1 = 0x12000011; | ||
465 | - cpu->isar.mvfr2 = 0x00000040; | ||
466 | - cpu->isar.id_pfr0 = 0x00000030; | ||
467 | - cpu->isar.id_pfr1 = 0x00000200; | ||
468 | - cpu->isar.id_dfr0 = 0x00100000; | ||
469 | - cpu->id_afr0 = 0x00000000; | ||
470 | - cpu->isar.id_mmfr0 = 0x00100030; | ||
471 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
472 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
473 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
474 | - cpu->isar.id_isar0 = 0x01101110; | ||
475 | - cpu->isar.id_isar1 = 0x02112000; | ||
476 | - cpu->isar.id_isar2 = 0x20232231; | ||
477 | - cpu->isar.id_isar3 = 0x01111131; | ||
478 | - cpu->isar.id_isar4 = 0x01310132; | ||
479 | - cpu->isar.id_isar5 = 0x00000000; | ||
480 | - cpu->isar.id_isar6 = 0x00000000; | ||
481 | -} | ||
482 | - | ||
483 | -static void cortex_m33_initfn(Object *obj) | ||
484 | -{ | ||
485 | - ARMCPU *cpu = ARM_CPU(obj); | ||
486 | - | ||
487 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
488 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
489 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
490 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
491 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
492 | - cpu->midr = 0x410fd213; /* r0p3 */ | ||
493 | - cpu->pmsav7_dregion = 16; | ||
494 | - cpu->sau_sregion = 8; | ||
495 | - cpu->isar.mvfr0 = 0x10110021; | ||
496 | - cpu->isar.mvfr1 = 0x11000011; | ||
497 | - cpu->isar.mvfr2 = 0x00000040; | ||
498 | - cpu->isar.id_pfr0 = 0x00000030; | ||
499 | - cpu->isar.id_pfr1 = 0x00000210; | ||
500 | - cpu->isar.id_dfr0 = 0x00200000; | ||
501 | - cpu->id_afr0 = 0x00000000; | ||
502 | - cpu->isar.id_mmfr0 = 0x00101F40; | ||
503 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
504 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
505 | - cpu->isar.id_mmfr3 = 0x00000000; | ||
506 | - cpu->isar.id_isar0 = 0x01101110; | ||
507 | - cpu->isar.id_isar1 = 0x02212000; | ||
508 | - cpu->isar.id_isar2 = 0x20232232; | ||
509 | - cpu->isar.id_isar3 = 0x01111131; | ||
510 | - cpu->isar.id_isar4 = 0x01310132; | ||
511 | - cpu->isar.id_isar5 = 0x00000000; | ||
512 | - cpu->isar.id_isar6 = 0x00000000; | ||
513 | - cpu->clidr = 0x00000000; | ||
514 | - cpu->ctr = 0x8000c000; | ||
515 | -} | ||
516 | - | ||
517 | -static void cortex_m55_initfn(Object *obj) | ||
518 | -{ | ||
519 | - ARMCPU *cpu = ARM_CPU(obj); | ||
520 | - | ||
521 | - set_feature(&cpu->env, ARM_FEATURE_V8); | ||
522 | - set_feature(&cpu->env, ARM_FEATURE_V8_1M); | ||
523 | - set_feature(&cpu->env, ARM_FEATURE_M); | ||
524 | - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); | ||
525 | - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); | ||
526 | - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); | ||
527 | - cpu->midr = 0x410fd221; /* r0p1 */ | ||
528 | - cpu->revidr = 0; | ||
529 | - cpu->pmsav7_dregion = 16; | ||
530 | - cpu->sau_sregion = 8; | ||
531 | - /* These are the MVFR* values for the FPU + full MVE configuration */ | ||
532 | - cpu->isar.mvfr0 = 0x10110221; | ||
533 | - cpu->isar.mvfr1 = 0x12100211; | ||
534 | - cpu->isar.mvfr2 = 0x00000040; | ||
535 | - cpu->isar.id_pfr0 = 0x20000030; | ||
536 | - cpu->isar.id_pfr1 = 0x00000230; | ||
537 | - cpu->isar.id_dfr0 = 0x10200000; | ||
538 | - cpu->id_afr0 = 0x00000000; | ||
539 | - cpu->isar.id_mmfr0 = 0x00111040; | ||
540 | - cpu->isar.id_mmfr1 = 0x00000000; | ||
541 | - cpu->isar.id_mmfr2 = 0x01000000; | ||
542 | - cpu->isar.id_mmfr3 = 0x00000011; | ||
543 | - cpu->isar.id_isar0 = 0x01103110; | ||
544 | - cpu->isar.id_isar1 = 0x02212000; | ||
545 | - cpu->isar.id_isar2 = 0x20232232; | ||
546 | - cpu->isar.id_isar3 = 0x01111131; | ||
547 | - cpu->isar.id_isar4 = 0x01310132; | ||
548 | - cpu->isar.id_isar5 = 0x00000000; | ||
549 | - cpu->isar.id_isar6 = 0x00000000; | ||
550 | - cpu->clidr = 0x00000000; /* caches not implemented */ | ||
551 | - cpu->ctr = 0x8303c003; | ||
552 | -} | ||
553 | - | ||
554 | static const ARMCPRegInfo cortexr5_cp_reginfo[] = { | ||
555 | /* Dummy the TCM region regs for the moment */ | ||
556 | { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, | ||
557 | @@ -XXX,XX +XXX,XX @@ static void pxa270c5_initfn(Object *obj) | ||
558 | cpu->reset_sctlr = 0x00000078; | ||
559 | } | ||
560 | |||
561 | -static const TCGCPUOps arm_v7m_tcg_ops = { | ||
562 | - .initialize = arm_translate_init, | ||
563 | - .synchronize_from_tb = arm_cpu_synchronize_from_tb, | ||
564 | - .debug_excp_handler = arm_debug_excp_handler, | ||
565 | - .restore_state_to_opc = arm_restore_state_to_opc, | ||
566 | - | ||
567 | -#ifdef CONFIG_USER_ONLY | ||
568 | - .record_sigsegv = arm_cpu_record_sigsegv, | ||
569 | - .record_sigbus = arm_cpu_record_sigbus, | ||
570 | -#else | ||
571 | - .tlb_fill = arm_cpu_tlb_fill, | ||
572 | - .cpu_exec_interrupt = arm_v7m_cpu_exec_interrupt, | ||
573 | - .do_interrupt = arm_v7m_cpu_do_interrupt, | ||
574 | - .do_transaction_failed = arm_cpu_do_transaction_failed, | ||
575 | - .do_unaligned_access = arm_cpu_do_unaligned_access, | ||
576 | - .adjust_watchpoint_address = arm_adjust_watchpoint_address, | ||
577 | - .debug_check_watchpoint = arm_debug_check_watchpoint, | ||
578 | - .debug_check_breakpoint = arm_debug_check_breakpoint, | ||
579 | -#endif /* !CONFIG_USER_ONLY */ | ||
122 | -}; | 580 | -}; |
123 | - | 581 | - |
124 | static void cadence_timer_update(CadenceTimerState *s) | 582 | -static void arm_v7m_class_init(ObjectClass *oc, void *data) |
125 | { | 583 | -{ |
126 | qemu_set_irq(s->irq, !!(s->reg_intr & s->reg_intr_en)); | 584 | - ARMCPUClass *acc = ARM_CPU_CLASS(oc); |
585 | - CPUClass *cc = CPU_CLASS(oc); | ||
586 | - | ||
587 | - acc->info = data; | ||
588 | - cc->tcg_ops = &arm_v7m_tcg_ops; | ||
589 | - cc->gdb_core_xml_file = "arm-m-profile.xml"; | ||
590 | -} | ||
591 | - | ||
592 | #ifndef TARGET_AARCH64 | ||
593 | /* | ||
594 | * -cpu max: a CPU with as many features enabled as our emulation supports. | ||
595 | @@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = { | ||
596 | { .name = "cortex-a8", .initfn = cortex_a8_initfn }, | ||
597 | { .name = "cortex-a9", .initfn = cortex_a9_initfn }, | ||
598 | { .name = "cortex-a15", .initfn = cortex_a15_initfn }, | ||
599 | - { .name = "cortex-m0", .initfn = cortex_m0_initfn, | ||
600 | - .class_init = arm_v7m_class_init }, | ||
601 | - { .name = "cortex-m3", .initfn = cortex_m3_initfn, | ||
602 | - .class_init = arm_v7m_class_init }, | ||
603 | - { .name = "cortex-m4", .initfn = cortex_m4_initfn, | ||
604 | - .class_init = arm_v7m_class_init }, | ||
605 | - { .name = "cortex-m7", .initfn = cortex_m7_initfn, | ||
606 | - .class_init = arm_v7m_class_init }, | ||
607 | - { .name = "cortex-m33", .initfn = cortex_m33_initfn, | ||
608 | - .class_init = arm_v7m_class_init }, | ||
609 | - { .name = "cortex-m55", .initfn = cortex_m55_initfn, | ||
610 | - .class_init = arm_v7m_class_init }, | ||
611 | { .name = "cortex-r5", .initfn = cortex_r5_initfn }, | ||
612 | { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, | ||
613 | { .name = "cortex-r52", .initfn = cortex_r52_initfn }, | ||
614 | diff --git a/target/arm/meson.build b/target/arm/meson.build | ||
615 | index XXXXXXX..XXXXXXX 100644 | ||
616 | --- a/target/arm/meson.build | ||
617 | +++ b/target/arm/meson.build | ||
618 | @@ -XXX,XX +XXX,XX @@ arm_system_ss.add(files( | ||
619 | 'ptw.c', | ||
620 | )) | ||
621 | |||
622 | +arm_user_ss = ss.source_set() | ||
623 | + | ||
624 | subdir('hvf') | ||
625 | |||
626 | if 'CONFIG_TCG' in config_all_accel | ||
627 | @@ -XXX,XX +XXX,XX @@ endif | ||
628 | |||
629 | target_arch += {'arm': arm_ss} | ||
630 | target_system_arch += {'arm': arm_system_ss} | ||
631 | +target_user_arch += {'arm': arm_user_ss} | ||
632 | diff --git a/target/arm/tcg/meson.build b/target/arm/tcg/meson.build | ||
633 | index XXXXXXX..XXXXXXX 100644 | ||
634 | --- a/target/arm/tcg/meson.build | ||
635 | +++ b/target/arm/tcg/meson.build | ||
636 | @@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'TARGET_AARCH64', if_true: files( | ||
637 | arm_system_ss.add(files( | ||
638 | 'psci.c', | ||
639 | )) | ||
640 | + | ||
641 | +arm_system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('cpu-v7m.c')) | ||
642 | +arm_user_ss.add(when: 'TARGET_AARCH64', if_false: files('cpu-v7m.c')) | ||
127 | -- | 643 | -- |
128 | 2.25.1 | 644 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
2 | 1 | ||
3 | Connect the 4 TTC timers on the ZynqMP. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
6 | Reviewed-by: Alistair Francis <alistair.francis@wdc.com> | ||
7 | Reviewed-by: Luc Michel <luc@lmichel.fr> | ||
8 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
9 | Message-id: 20220331222017.2914409-3-edgar.iglesias@gmail.com | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/arm/xlnx-zynqmp.h | 4 ++++ | ||
13 | hw/arm/xlnx-zynqmp.c | 22 ++++++++++++++++++++++ | ||
14 | 2 files changed, 26 insertions(+) | ||
15 | |||
16 | diff --git a/include/hw/arm/xlnx-zynqmp.h b/include/hw/arm/xlnx-zynqmp.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/xlnx-zynqmp.h | ||
19 | +++ b/include/hw/arm/xlnx-zynqmp.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
21 | #include "hw/or-irq.h" | ||
22 | #include "hw/misc/xlnx-zynqmp-apu-ctrl.h" | ||
23 | #include "hw/misc/xlnx-zynqmp-crf.h" | ||
24 | +#include "hw/timer/cadence_ttc.h" | ||
25 | |||
26 | #define TYPE_XLNX_ZYNQMP "xlnx-zynqmp" | ||
27 | OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) | ||
28 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxZynqMPState, XLNX_ZYNQMP) | ||
29 | #define XLNX_ZYNQMP_MAX_RAM_SIZE (XLNX_ZYNQMP_MAX_LOW_RAM_SIZE + \ | ||
30 | XLNX_ZYNQMP_MAX_HIGH_RAM_SIZE) | ||
31 | |||
32 | +#define XLNX_ZYNQMP_NUM_TTC 4 | ||
33 | + | ||
34 | /* | ||
35 | * Unimplemented mmio regions needed to boot some images. | ||
36 | */ | ||
37 | @@ -XXX,XX +XXX,XX @@ struct XlnxZynqMPState { | ||
38 | qemu_or_irq qspi_irq_orgate; | ||
39 | XlnxZynqMPAPUCtrl apu_ctrl; | ||
40 | XlnxZynqMPCRF crf; | ||
41 | + CadenceTTCState ttc[XLNX_ZYNQMP_NUM_TTC]; | ||
42 | |||
43 | char *boot_cpu; | ||
44 | ARMCPU *boot_cpu_ptr; | ||
45 | diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c | ||
46 | index XXXXXXX..XXXXXXX 100644 | ||
47 | --- a/hw/arm/xlnx-zynqmp.c | ||
48 | +++ b/hw/arm/xlnx-zynqmp.c | ||
49 | @@ -XXX,XX +XXX,XX @@ | ||
50 | #define APU_ADDR 0xfd5c0000 | ||
51 | #define APU_IRQ 153 | ||
52 | |||
53 | +#define TTC0_ADDR 0xFF110000 | ||
54 | +#define TTC0_IRQ 36 | ||
55 | + | ||
56 | #define IPI_ADDR 0xFF300000 | ||
57 | #define IPI_IRQ 64 | ||
58 | |||
59 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_create_crf(XlnxZynqMPState *s, qemu_irq *gic) | ||
60 | sysbus_connect_irq(sbd, 0, gic[CRF_IRQ]); | ||
61 | } | ||
62 | |||
63 | +static void xlnx_zynqmp_create_ttc(XlnxZynqMPState *s, qemu_irq *gic) | ||
64 | +{ | ||
65 | + SysBusDevice *sbd; | ||
66 | + int i, irq; | ||
67 | + | ||
68 | + for (i = 0; i < XLNX_ZYNQMP_NUM_TTC; i++) { | ||
69 | + object_initialize_child(OBJECT(s), "ttc[*]", &s->ttc[i], | ||
70 | + TYPE_CADENCE_TTC); | ||
71 | + sbd = SYS_BUS_DEVICE(&s->ttc[i]); | ||
72 | + | ||
73 | + sysbus_realize(sbd, &error_fatal); | ||
74 | + sysbus_mmio_map(sbd, 0, TTC0_ADDR + i * 0x10000); | ||
75 | + for (irq = 0; irq < 3; irq++) { | ||
76 | + sysbus_connect_irq(sbd, irq, gic[TTC0_IRQ + i * 3 + irq]); | ||
77 | + } | ||
78 | + } | ||
79 | +} | ||
80 | + | ||
81 | static void xlnx_zynqmp_create_unimp_mmio(XlnxZynqMPState *s) | ||
82 | { | ||
83 | static const struct UnimpInfo { | ||
84 | @@ -XXX,XX +XXX,XX @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) | ||
85 | xlnx_zynqmp_create_efuse(s, gic_spi); | ||
86 | xlnx_zynqmp_create_apu_ctrl(s, gic_spi); | ||
87 | xlnx_zynqmp_create_crf(s, gic_spi); | ||
88 | + xlnx_zynqmp_create_ttc(s, gic_spi); | ||
89 | xlnx_zynqmp_create_unimp_mmio(s); | ||
90 | |||
91 | for (i = 0; i < XLNX_ZYNQMP_NUM_GDMA_CH; i++) { | ||
92 | -- | ||
93 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
2 | 1 | ||
3 | Create an APU CPU Cluster. This is in preparation to add the RPU. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
6 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
7 | Message-id: 20220406174303.2022038-2-edgar.iglesias@xilinx.com | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | --- | ||
10 | include/hw/arm/xlnx-versal.h | 2 ++ | ||
11 | hw/arm/xlnx-versal.c | 9 ++++++++- | ||
12 | 2 files changed, 10 insertions(+), 1 deletion(-) | ||
13 | |||
14 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/include/hw/arm/xlnx-versal.h | ||
17 | +++ b/include/hw/arm/xlnx-versal.h | ||
18 | @@ -XXX,XX +XXX,XX @@ | ||
19 | |||
20 | #include "hw/sysbus.h" | ||
21 | #include "hw/arm/boot.h" | ||
22 | +#include "hw/cpu/cluster.h" | ||
23 | #include "hw/or-irq.h" | ||
24 | #include "hw/sd/sdhci.h" | ||
25 | #include "hw/intc/arm_gicv3.h" | ||
26 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
27 | struct { | ||
28 | struct { | ||
29 | MemoryRegion mr; | ||
30 | + CPUClusterState cluster; | ||
31 | ARMCPU cpu[XLNX_VERSAL_NR_ACPUS]; | ||
32 | GICv3State gic; | ||
33 | } apu; | ||
34 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/arm/xlnx-versal.c | ||
37 | +++ b/hw/arm/xlnx-versal.c | ||
38 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | ||
39 | { | ||
40 | int i; | ||
41 | |||
42 | + object_initialize_child(OBJECT(s), "apu-cluster", &s->fpd.apu.cluster, | ||
43 | + TYPE_CPU_CLUSTER); | ||
44 | + qdev_prop_set_uint32(DEVICE(&s->fpd.apu.cluster), "cluster-id", 0); | ||
45 | + | ||
46 | for (i = 0; i < ARRAY_SIZE(s->fpd.apu.cpu); i++) { | ||
47 | Object *obj; | ||
48 | |||
49 | - object_initialize_child(OBJECT(s), "apu-cpu[*]", &s->fpd.apu.cpu[i], | ||
50 | + object_initialize_child(OBJECT(&s->fpd.apu.cluster), | ||
51 | + "apu-cpu[*]", &s->fpd.apu.cpu[i], | ||
52 | XLNX_VERSAL_ACPU_TYPE); | ||
53 | obj = OBJECT(&s->fpd.apu.cpu[i]); | ||
54 | if (i) { | ||
55 | @@ -XXX,XX +XXX,XX @@ static void versal_create_apu_cpus(Versal *s) | ||
56 | &error_abort); | ||
57 | qdev_realize(DEVICE(obj), NULL, &error_fatal); | ||
58 | } | ||
59 | + | ||
60 | + qdev_realize(DEVICE(&s->fpd.apu.cluster), NULL, &error_fatal); | ||
61 | } | ||
62 | |||
63 | static void versal_create_apu_gic(Versal *s, qemu_irq *pic) | ||
64 | -- | ||
65 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
2 | 1 | ||
3 | Connect the CRL (Clock Reset LPD) to the Versal SoC. | ||
4 | |||
5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> | ||
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
8 | Message-id: 20220406174303.2022038-5-edgar.iglesias@xilinx.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/xlnx-versal.h | 4 +++ | ||
12 | hw/arm/xlnx-versal.c | 54 ++++++++++++++++++++++++++++++++++-- | ||
13 | 2 files changed, 56 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/arm/xlnx-versal.h | ||
18 | +++ b/include/hw/arm/xlnx-versal.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "hw/nvram/xlnx-versal-efuse.h" | ||
21 | #include "hw/ssi/xlnx-versal-ospi.h" | ||
22 | #include "hw/dma/xlnx_csu_dma.h" | ||
23 | +#include "hw/misc/xlnx-versal-crl.h" | ||
24 | #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" | ||
25 | |||
26 | #define TYPE_XLNX_VERSAL "xlnx-versal" | ||
27 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
28 | qemu_or_irq irq_orgate; | ||
29 | XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; | ||
30 | } xram; | ||
31 | + | ||
32 | + XlnxVersalCRL crl; | ||
33 | } lpd; | ||
34 | |||
35 | /* The Platform Management Controller subsystem. */ | ||
36 | @@ -XXX,XX +XXX,XX @@ struct Versal { | ||
37 | #define VERSAL_TIMER_NS_EL1_IRQ 14 | ||
38 | #define VERSAL_TIMER_NS_EL2_IRQ 10 | ||
39 | |||
40 | +#define VERSAL_CRL_IRQ 10 | ||
41 | #define VERSAL_UART0_IRQ_0 18 | ||
42 | #define VERSAL_UART1_IRQ_0 19 | ||
43 | #define VERSAL_USB0_IRQ_0 22 | ||
44 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c | ||
45 | index XXXXXXX..XXXXXXX 100644 | ||
46 | --- a/hw/arm/xlnx-versal.c | ||
47 | +++ b/hw/arm/xlnx-versal.c | ||
48 | @@ -XXX,XX +XXX,XX @@ static void versal_create_ospi(Versal *s, qemu_irq *pic) | ||
49 | qdev_connect_gpio_out(orgate, 0, pic[VERSAL_OSPI_IRQ]); | ||
50 | } | ||
51 | |||
52 | +static void versal_create_crl(Versal *s, qemu_irq *pic) | ||
53 | +{ | ||
54 | + SysBusDevice *sbd; | ||
55 | + int i; | ||
56 | + | ||
57 | + object_initialize_child(OBJECT(s), "crl", &s->lpd.crl, | ||
58 | + TYPE_XLNX_VERSAL_CRL); | ||
59 | + sbd = SYS_BUS_DEVICE(&s->lpd.crl); | ||
60 | + | ||
61 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { | ||
62 | + g_autofree gchar *name = g_strdup_printf("cpu_r5[%d]", i); | ||
63 | + | ||
64 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
65 | + name, OBJECT(&s->lpd.rpu.cpu[i]), | ||
66 | + &error_abort); | ||
67 | + } | ||
68 | + | ||
69 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.gem); i++) { | ||
70 | + g_autofree gchar *name = g_strdup_printf("gem[%d]", i); | ||
71 | + | ||
72 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
73 | + name, OBJECT(&s->lpd.iou.gem[i]), | ||
74 | + &error_abort); | ||
75 | + } | ||
76 | + | ||
77 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.adma); i++) { | ||
78 | + g_autofree gchar *name = g_strdup_printf("adma[%d]", i); | ||
79 | + | ||
80 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
81 | + name, OBJECT(&s->lpd.iou.adma[i]), | ||
82 | + &error_abort); | ||
83 | + } | ||
84 | + | ||
85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.uart); i++) { | ||
86 | + g_autofree gchar *name = g_strdup_printf("uart[%d]", i); | ||
87 | + | ||
88 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
89 | + name, OBJECT(&s->lpd.iou.uart[i]), | ||
90 | + &error_abort); | ||
91 | + } | ||
92 | + | ||
93 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
94 | + "usb", OBJECT(&s->lpd.iou.usb), | ||
95 | + &error_abort); | ||
96 | + | ||
97 | + sysbus_realize(sbd, &error_fatal); | ||
98 | + memory_region_add_subregion(&s->mr_ps, MM_CRL, | ||
99 | + sysbus_mmio_get_region(sbd, 0)); | ||
100 | + sysbus_connect_irq(sbd, 0, pic[VERSAL_CRL_IRQ]); | ||
101 | +} | ||
102 | + | ||
103 | /* This takes the board allocated linear DDR memory and creates aliases | ||
104 | * for each split DDR range/aperture on the Versal address map. | ||
105 | */ | ||
106 | @@ -XXX,XX +XXX,XX @@ static void versal_unimp(Versal *s) | ||
107 | |||
108 | versal_unimp_area(s, "psm", &s->mr_ps, | ||
109 | MM_PSM_START, MM_PSM_END - MM_PSM_START); | ||
110 | - versal_unimp_area(s, "crl", &s->mr_ps, | ||
111 | - MM_CRL, MM_CRL_SIZE); | ||
112 | versal_unimp_area(s, "crf", &s->mr_ps, | ||
113 | MM_FPD_CRF, MM_FPD_CRF_SIZE); | ||
114 | versal_unimp_area(s, "apu", &s->mr_ps, | ||
115 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
116 | versal_create_efuse(s, pic); | ||
117 | versal_create_pmc_iou_slcr(s, pic); | ||
118 | versal_create_ospi(s, pic); | ||
119 | + versal_create_crl(s, pic); | ||
120 | versal_map_ddr(s); | ||
121 | versal_unimp(s); | ||
122 | |||
123 | -- | ||
124 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Now we have removed the only use of TYPE_EXYNOS4210_IRQ_GATE we can | ||
2 | delete the device entirely. | ||
3 | 1 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com> | ||
6 | Message-id: 20220404154658.565020-3-peter.maydell@linaro.org | ||
7 | --- | ||
8 | hw/intc/exynos4210_gic.c | 107 --------------------------------------- | ||
9 | 1 file changed, 107 deletions(-) | ||
10 | |||
11 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/intc/exynos4210_gic.c | ||
14 | +++ b/hw/intc/exynos4210_gic.c | ||
15 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_gic_register_types(void) | ||
16 | } | ||
17 | |||
18 | type_init(exynos4210_gic_register_types) | ||
19 | - | ||
20 | -/* IRQ OR Gate struct. | ||
21 | - * | ||
22 | - * This device models an OR gate. There are n_in input qdev gpio lines and one | ||
23 | - * output sysbus IRQ line. The output IRQ level is formed as OR between all | ||
24 | - * gpio inputs. | ||
25 | - */ | ||
26 | - | ||
27 | -#define TYPE_EXYNOS4210_IRQ_GATE "exynos4210.irq_gate" | ||
28 | -OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210IRQGateState, EXYNOS4210_IRQ_GATE) | ||
29 | - | ||
30 | -struct Exynos4210IRQGateState { | ||
31 | - SysBusDevice parent_obj; | ||
32 | - | ||
33 | - uint32_t n_in; /* inputs amount */ | ||
34 | - uint32_t *level; /* input levels */ | ||
35 | - qemu_irq out; /* output IRQ */ | ||
36 | -}; | ||
37 | - | ||
38 | -static Property exynos4210_irq_gate_properties[] = { | ||
39 | - DEFINE_PROP_UINT32("n_in", Exynos4210IRQGateState, n_in, 1), | ||
40 | - DEFINE_PROP_END_OF_LIST(), | ||
41 | -}; | ||
42 | - | ||
43 | -static const VMStateDescription vmstate_exynos4210_irq_gate = { | ||
44 | - .name = "exynos4210.irq_gate", | ||
45 | - .version_id = 2, | ||
46 | - .minimum_version_id = 2, | ||
47 | - .fields = (VMStateField[]) { | ||
48 | - VMSTATE_VBUFFER_UINT32(level, Exynos4210IRQGateState, 1, NULL, n_in), | ||
49 | - VMSTATE_END_OF_LIST() | ||
50 | - } | ||
51 | -}; | ||
52 | - | ||
53 | -/* Process a change in IRQ input. */ | ||
54 | -static void exynos4210_irq_gate_handler(void *opaque, int irq, int level) | ||
55 | -{ | ||
56 | - Exynos4210IRQGateState *s = (Exynos4210IRQGateState *)opaque; | ||
57 | - uint32_t i; | ||
58 | - | ||
59 | - assert(irq < s->n_in); | ||
60 | - | ||
61 | - s->level[irq] = level; | ||
62 | - | ||
63 | - for (i = 0; i < s->n_in; i++) { | ||
64 | - if (s->level[i] >= 1) { | ||
65 | - qemu_irq_raise(s->out); | ||
66 | - return; | ||
67 | - } | ||
68 | - } | ||
69 | - | ||
70 | - qemu_irq_lower(s->out); | ||
71 | -} | ||
72 | - | ||
73 | -static void exynos4210_irq_gate_reset(DeviceState *d) | ||
74 | -{ | ||
75 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(d); | ||
76 | - | ||
77 | - memset(s->level, 0, s->n_in * sizeof(*s->level)); | ||
78 | -} | ||
79 | - | ||
80 | -/* | ||
81 | - * IRQ Gate initialization. | ||
82 | - */ | ||
83 | -static void exynos4210_irq_gate_init(Object *obj) | ||
84 | -{ | ||
85 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(obj); | ||
86 | - SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
87 | - | ||
88 | - sysbus_init_irq(sbd, &s->out); | ||
89 | -} | ||
90 | - | ||
91 | -static void exynos4210_irq_gate_realize(DeviceState *dev, Error **errp) | ||
92 | -{ | ||
93 | - Exynos4210IRQGateState *s = EXYNOS4210_IRQ_GATE(dev); | ||
94 | - | ||
95 | - /* Allocate general purpose input signals and connect a handler to each of | ||
96 | - * them */ | ||
97 | - qdev_init_gpio_in(dev, exynos4210_irq_gate_handler, s->n_in); | ||
98 | - | ||
99 | - s->level = g_malloc0(s->n_in * sizeof(*s->level)); | ||
100 | -} | ||
101 | - | ||
102 | -static void exynos4210_irq_gate_class_init(ObjectClass *klass, void *data) | ||
103 | -{ | ||
104 | - DeviceClass *dc = DEVICE_CLASS(klass); | ||
105 | - | ||
106 | - dc->reset = exynos4210_irq_gate_reset; | ||
107 | - dc->vmsd = &vmstate_exynos4210_irq_gate; | ||
108 | - device_class_set_props(dc, exynos4210_irq_gate_properties); | ||
109 | - dc->realize = exynos4210_irq_gate_realize; | ||
110 | -} | ||
111 | - | ||
112 | -static const TypeInfo exynos4210_irq_gate_info = { | ||
113 | - .name = TYPE_EXYNOS4210_IRQ_GATE, | ||
114 | - .parent = TYPE_SYS_BUS_DEVICE, | ||
115 | - .instance_size = sizeof(Exynos4210IRQGateState), | ||
116 | - .instance_init = exynos4210_irq_gate_init, | ||
117 | - .class_init = exynos4210_irq_gate_class_init, | ||
118 | -}; | ||
119 | - | ||
120 | -static void exynos4210_irq_gate_register_types(void) | ||
121 | -{ | ||
122 | - type_register_static(&exynos4210_irq_gate_info); | ||
123 | -} | ||
124 | - | ||
125 | -type_init(exynos4210_irq_gate_register_types) | ||
126 | -- | ||
127 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The exynos4210 SoC mostly creates its child devices as if it were | ||
2 | board code. This includes the a9mpcore object. Switch that to a | ||
3 | new-style "embedded in the state struct" creation, because in the | ||
4 | next commit we're going to want to refer to the object again further | ||
5 | down in the exynos4210_realize() function. | ||
6 | 1 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
9 | Message-id: 20220404154658.565020-4-peter.maydell@linaro.org | ||
10 | --- | ||
11 | include/hw/arm/exynos4210.h | 2 ++ | ||
12 | hw/arm/exynos4210.c | 11 ++++++----- | ||
13 | 2 files changed, 8 insertions(+), 5 deletions(-) | ||
14 | |||
15 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/arm/exynos4210.h | ||
18 | +++ b/include/hw/arm/exynos4210.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | |||
21 | #include "hw/or-irq.h" | ||
22 | #include "hw/sysbus.h" | ||
23 | +#include "hw/cpu/a9mpcore.h" | ||
24 | #include "target/arm/cpu-qom.h" | ||
25 | #include "qom/object.h" | ||
26 | |||
27 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
28 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | ||
29 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | ||
30 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
31 | + A9MPPrivState a9mpcore; | ||
32 | }; | ||
33 | |||
34 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
35 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/hw/arm/exynos4210.c | ||
38 | +++ b/hw/arm/exynos4210.c | ||
39 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
40 | } | ||
41 | |||
42 | /* Private memory region and Internal GIC */ | ||
43 | - dev = qdev_new(TYPE_A9MPCORE_PRIV); | ||
44 | - qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | ||
45 | - busdev = SYS_BUS_DEVICE(dev); | ||
46 | - sysbus_realize_and_unref(busdev, &error_fatal); | ||
47 | + qdev_prop_set_uint32(DEVICE(&s->a9mpcore), "num-cpu", EXYNOS4210_NCPUS); | ||
48 | + busdev = SYS_BUS_DEVICE(&s->a9mpcore); | ||
49 | + sysbus_realize(busdev, &error_fatal); | ||
50 | sysbus_mmio_map(busdev, 0, EXYNOS4210_SMP_PRIVATE_BASE_ADDR); | ||
51 | for (n = 0; n < EXYNOS4210_NCPUS; n++) { | ||
52 | sysbus_connect_irq(busdev, n, | ||
53 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
54 | } | ||
55 | for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | ||
56 | - s->irqs.int_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
57 | + s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n); | ||
58 | } | ||
59 | |||
60 | /* Cache controller */ | ||
61 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) | ||
62 | g_autofree char *name = g_strdup_printf("cpu-irq-orgate%d", i); | ||
63 | object_initialize_child(obj, name, &s->cpu_irq_orgate[i], TYPE_OR_IRQ); | ||
64 | } | ||
65 | + | ||
66 | + object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
67 | } | ||
68 | |||
69 | static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
70 | -- | ||
71 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The only time we use the int_gic_irq[] array in the Exynos4210Irq | ||
2 | struct is in the exynos4210_realize() function: we initialize it with | ||
3 | the GPIO inputs of the a9mpcore device, and then a bit later on we | ||
4 | connect those to the outputs of the internal combiner. Now that the | ||
5 | a9mpcore object is easily accessible as s->a9mpcore we can make the | ||
6 | connection directly from one device to the other without going via | ||
7 | this array. | ||
8 | 1 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-5-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 1 - | ||
14 | hw/arm/exynos4210.c | 6 ++---- | ||
15 | 2 files changed, 2 insertions(+), 5 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/exynos4210.h | ||
20 | +++ b/include/hw/arm/exynos4210.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | typedef struct Exynos4210Irq { | ||
23 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
24 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
25 | - qemu_irq int_gic_irq[EXYNOS4210_INT_GIC_NIRQ]; | ||
26 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | ||
27 | qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
28 | } Exynos4210Irq; | ||
29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/exynos4210.c | ||
32 | +++ b/hw/arm/exynos4210.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
34 | sysbus_connect_irq(busdev, n, | ||
35 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 0)); | ||
36 | } | ||
37 | - for (n = 0; n < EXYNOS4210_INT_GIC_NIRQ; n++) { | ||
38 | - s->irqs.int_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->a9mpcore), n); | ||
39 | - } | ||
40 | |||
41 | /* Cache controller */ | ||
42 | sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL); | ||
43 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
44 | busdev = SYS_BUS_DEVICE(dev); | ||
45 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
46 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
47 | - sysbus_connect_irq(busdev, n, s->irqs.int_gic_irq[n]); | ||
48 | + sysbus_connect_irq(busdev, n, | ||
49 | + qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); | ||
50 | } | ||
51 | exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); | ||
52 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); | ||
53 | -- | ||
54 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Fix a missing set of spaces around '-' in the definition of | ||
2 | combiner_grp_to_gic_id[]. We're about to move this code, so | ||
3 | fix the style issue first to keep checkpatch happy with the | ||
4 | code-motion patch. | ||
5 | 1 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
8 | Message-id: 20220404154658.565020-7-peter.maydell@linaro.org | ||
9 | --- | ||
10 | hw/intc/exynos4210_gic.c | 2 +- | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/hw/intc/exynos4210_gic.c | ||
16 | +++ b/hw/intc/exynos4210_gic.c | ||
17 | @@ -XXX,XX +XXX,XX @@ enum ExtInt { | ||
18 | */ | ||
19 | |||
20 | static const uint32_t | ||
21 | -combiner_grp_to_gic_id[64-EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
22 | +combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
23 | /* int combiner groups 16-19 */ | ||
24 | { }, { }, { }, { }, | ||
25 | /* int combiner group 20 */ | ||
26 | -- | ||
27 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The only time we use the ext_gic_irq[] array in the Exynos4210Irq | ||
2 | struct is during realize of the SoC -- we initialize it with the | ||
3 | input IRQs of the external GIC device, and then connect those to | ||
4 | outputs of other devices further on in realize (including in the | ||
5 | exynos4210_init_board_irqs() function). Now that the ext_gic object | ||
6 | is easily accessible as s->ext_gic we can make the connections | ||
7 | directly from one device to the other without going via this array. | ||
8 | 1 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-10-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 1 - | ||
14 | hw/arm/exynos4210.c | 12 ++++++------ | ||
15 | 2 files changed, 6 insertions(+), 7 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | ||
19 | --- a/include/hw/arm/exynos4210.h | ||
20 | +++ b/include/hw/arm/exynos4210.h | ||
21 | @@ -XXX,XX +XXX,XX @@ | ||
22 | typedef struct Exynos4210Irq { | ||
23 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
24 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
25 | - qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | ||
26 | } Exynos4210Irq; | ||
27 | |||
28 | struct Exynos4210State { | ||
29 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/arm/exynos4210.c | ||
32 | +++ b/hw/arm/exynos4210.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
34 | { | ||
35 | uint32_t grp, bit, irq_id, n; | ||
36 | Exynos4210Irq *is = &s->irqs; | ||
37 | + DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
38 | |||
39 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
40 | irq_id = 0; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
42 | } | ||
43 | if (irq_id) { | ||
44 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
45 | - is->ext_gic_irq[irq_id - 32]); | ||
46 | + qdev_get_gpio_in(extgicdev, | ||
47 | + irq_id - 32)); | ||
48 | } else { | ||
49 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
50 | is->ext_combiner_irq[n]); | ||
51 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
52 | |||
53 | if (irq_id) { | ||
54 | s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
55 | - is->ext_gic_irq[irq_id - 32]); | ||
56 | + qdev_get_gpio_in(extgicdev, | ||
57 | + irq_id - 32)); | ||
58 | } | ||
59 | } | ||
60 | } | ||
61 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
62 | sysbus_connect_irq(busdev, n, | ||
63 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
64 | } | ||
65 | - for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
66 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); | ||
67 | - } | ||
68 | |||
69 | /* Internal Interrupt Combiner */ | ||
70 | dev = qdev_new("exynos4210.combiner"); | ||
71 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
72 | busdev = SYS_BUS_DEVICE(dev); | ||
73 | sysbus_realize_and_unref(busdev, &error_fatal); | ||
74 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { | ||
75 | - sysbus_connect_irq(busdev, n, s->irqs.ext_gic_irq[n]); | ||
76 | + sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); | ||
77 | } | ||
78 | exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); | ||
79 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); | ||
80 | -- | ||
81 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Delete a couple of #defines which are never used. | ||
2 | 1 | ||
3 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
4 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
5 | Message-id: 20220404154658.565020-12-peter.maydell@linaro.org | ||
6 | --- | ||
7 | include/hw/arm/exynos4210.h | 4 ---- | ||
8 | 1 file changed, 4 deletions(-) | ||
9 | |||
10 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
11 | index XXXXXXX..XXXXXXX 100644 | ||
12 | --- a/include/hw/arm/exynos4210.h | ||
13 | +++ b/include/hw/arm/exynos4210.h | ||
14 | @@ -XXX,XX +XXX,XX @@ | ||
15 | #define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \ | ||
16 | (EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ * 8) | ||
17 | |||
18 | -/* IRQs number for external and internal GIC */ | ||
19 | -#define EXYNOS4210_EXT_GIC_NIRQ (160-32) | ||
20 | -#define EXYNOS4210_INT_GIC_NIRQ 64 | ||
21 | - | ||
22 | #define EXYNOS4210_I2C_NUMBER 9 | ||
23 | |||
24 | #define EXYNOS4210_NUM_DMA 3 | ||
25 | -- | ||
26 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | In exynos4210_init_board_irqs(), the loop that handles IRQ lines that | ||
2 | are in a range that applies to the internal combiner only creates a | ||
3 | splitter for those interrupts which go to both the internal combiner | ||
4 | and to the external GIC, but it does nothing at all for the | ||
5 | interrupts which don't go to the external GIC, leaving the | ||
6 | irq_table[] array element empty for those. (This will result in | ||
7 | those interrupts simply being lost, not in a QEMU crash.) | ||
8 | 1 | ||
9 | I don't have a reliable datasheet for this SoC, but since we do wire | ||
10 | up one interrupt line in this category (the HDMI I2C device on | ||
11 | interrupt 16,1), this seems like it must be a bug in the existing | ||
12 | QEMU code. Fill in the irq_table[] entries where we're not splitting | ||
13 | the IRQ to both the internal combiner and the external GIC with the | ||
14 | IRQ line of the internal combiner. (That is, these IRQ lines go to | ||
15 | just one device, not multiple.) | ||
16 | |||
17 | This bug didn't have any visible guest effects because the only | ||
18 | implemented device that was affected was the HDMI I2C controller, | ||
19 | and we never connect any I2C devices to that bus. | ||
20 | |||
21 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
22 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
23 | Message-id: 20220404154658.565020-14-peter.maydell@linaro.org | ||
24 | --- | ||
25 | hw/arm/exynos4210.c | 2 ++ | ||
26 | 1 file changed, 2 insertions(+) | ||
27 | |||
28 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
29 | index XXXXXXX..XXXXXXX 100644 | ||
30 | --- a/hw/arm/exynos4210.c | ||
31 | +++ b/hw/arm/exynos4210.c | ||
32 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
33 | qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
34 | qdev_connect_gpio_out(splitter, 1, | ||
35 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
36 | + } else { | ||
37 | + s->irq_table[n] = is->int_combiner_irq[n]; | ||
38 | } | ||
39 | } | ||
40 | /* | ||
41 | -- | ||
42 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Currently for the interrupts MCT_G0 and MCT_G1 which are | ||
2 | the only ones in the input range of the external combiner | ||
3 | and which are also wired to the external GIC, we connect | ||
4 | them only to the internal combiner and the external GIC. | ||
5 | This seems likely to be a bug, as all other interrupts | ||
6 | which are in the input range of both combiners are | ||
7 | connected to both combiners. (The fact that the code in | ||
8 | exynos4210_combiner_get_gpioin() is also trying to wire | ||
9 | up these inputs on both combiners also suggests this.) | ||
10 | 1 | ||
11 | Wire these interrupts up to both combiners, like the rest. | ||
12 | |||
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
15 | Message-id: 20220404154658.565020-15-peter.maydell@linaro.org | ||
16 | --- | ||
17 | hw/arm/exynos4210.c | 7 +++---- | ||
18 | 1 file changed, 3 insertions(+), 4 deletions(-) | ||
19 | |||
20 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
21 | index XXXXXXX..XXXXXXX 100644 | ||
22 | --- a/hw/arm/exynos4210.c | ||
23 | +++ b/hw/arm/exynos4210.c | ||
24 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
25 | |||
26 | assert(splitcount < EXYNOS4210_NUM_SPLITTERS); | ||
27 | splitter = DEVICE(&s->splitter[splitcount]); | ||
28 | - qdev_prop_set_uint16(splitter, "num-lines", 2); | ||
29 | + qdev_prop_set_uint16(splitter, "num-lines", irq_id ? 3 : 2); | ||
30 | qdev_realize(splitter, NULL, &error_abort); | ||
31 | splitcount++; | ||
32 | s->irq_table[n] = qdev_get_gpio_in(splitter, 0); | ||
33 | qdev_connect_gpio_out(splitter, 0, is->int_combiner_irq[n]); | ||
34 | + qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
35 | if (irq_id) { | ||
36 | - qdev_connect_gpio_out(splitter, 1, | ||
37 | + qdev_connect_gpio_out(splitter, 2, | ||
38 | qdev_get_gpio_in(extgicdev, irq_id - 32)); | ||
39 | - } else { | ||
40 | - qdev_connect_gpio_out(splitter, 1, is->ext_combiner_irq[n]); | ||
41 | } | ||
42 | } | ||
43 | for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
44 | -- | ||
45 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zongyuan Li <zongyuan.li@smartx.com> | ||
2 | 1 | ||
3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20220324181557.203805-2-zongyuan.li@smartx.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/arm/realview.c | 33 ++++++++++++++++++++++++--------- | ||
9 | 1 file changed, 24 insertions(+), 9 deletions(-) | ||
10 | |||
11 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/arm/realview.c | ||
14 | +++ b/hw/arm/realview.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | #include "hw/sysbus.h" | ||
17 | #include "hw/arm/boot.h" | ||
18 | #include "hw/arm/primecell.h" | ||
19 | +#include "hw/core/split-irq.h" | ||
20 | #include "hw/net/lan9118.h" | ||
21 | #include "hw/net/smc91c111.h" | ||
22 | #include "hw/pci/pci.h" | ||
23 | +#include "hw/qdev-core.h" | ||
24 | #include "net/net.h" | ||
25 | #include "sysemu/sysemu.h" | ||
26 | #include "hw/boards.h" | ||
27 | @@ -XXX,XX +XXX,XX @@ static const int realview_board_id[] = { | ||
28 | 0x76d | ||
29 | }; | ||
30 | |||
31 | +static void split_irq_from_named(DeviceState *src, const char* outname, | ||
32 | + qemu_irq out1, qemu_irq out2) { | ||
33 | + DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ); | ||
34 | + | ||
35 | + qdev_prop_set_uint32(splitter, "num-lines", 2); | ||
36 | + | ||
37 | + qdev_realize_and_unref(splitter, NULL, &error_fatal); | ||
38 | + | ||
39 | + qdev_connect_gpio_out(splitter, 0, out1); | ||
40 | + qdev_connect_gpio_out(splitter, 1, out2); | ||
41 | + qdev_connect_gpio_out_named(src, outname, 0, | ||
42 | + qdev_get_gpio_in(splitter, 0)); | ||
43 | +} | ||
44 | + | ||
45 | static void realview_init(MachineState *machine, | ||
46 | enum realview_board_type board_type) | ||
47 | { | ||
48 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, | ||
49 | DeviceState *dev, *sysctl, *gpio2, *pl041; | ||
50 | SysBusDevice *busdev; | ||
51 | qemu_irq pic[64]; | ||
52 | - qemu_irq mmc_irq[2]; | ||
53 | PCIBus *pci_bus = NULL; | ||
54 | NICInfo *nd; | ||
55 | DriveInfo *dinfo; | ||
56 | @@ -XXX,XX +XXX,XX @@ static void realview_init(MachineState *machine, | ||
57 | * and the PL061 has them the other way about. Also the card | ||
58 | * detect line is inverted. | ||
59 | */ | ||
60 | - mmc_irq[0] = qemu_irq_split( | ||
61 | - qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), | ||
62 | - qdev_get_gpio_in(gpio2, 1)); | ||
63 | - mmc_irq[1] = qemu_irq_split( | ||
64 | - qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), | ||
65 | - qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); | ||
66 | - qdev_connect_gpio_out_named(dev, "card-read-only", 0, mmc_irq[0]); | ||
67 | - qdev_connect_gpio_out_named(dev, "card-inserted", 0, mmc_irq[1]); | ||
68 | + split_irq_from_named(dev, "card-read-only", | ||
69 | + qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), | ||
70 | + qdev_get_gpio_in(gpio2, 1)); | ||
71 | + | ||
72 | + split_irq_from_named(dev, "card-inserted", | ||
73 | + qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), | ||
74 | + qemu_irq_invert(qdev_get_gpio_in(gpio2, 0))); | ||
75 | + | ||
76 | dinfo = drive_get(IF_SD, 0, 0); | ||
77 | if (dinfo) { | ||
78 | DeviceState *card; | ||
79 | -- | ||
80 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zongyuan Li <zongyuan.li@smartx.com> | ||
2 | 1 | ||
3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20220324181557.203805-3-zongyuan.li@smartx.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
7 | --- | ||
8 | hw/arm/stellaris.c | 15 +++++++++++++-- | ||
9 | 1 file changed, 13 insertions(+), 2 deletions(-) | ||
10 | |||
11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c | ||
12 | index XXXXXXX..XXXXXXX 100644 | ||
13 | --- a/hw/arm/stellaris.c | ||
14 | +++ b/hw/arm/stellaris.c | ||
15 | @@ -XXX,XX +XXX,XX @@ | ||
16 | |||
17 | #include "qemu/osdep.h" | ||
18 | #include "qapi/error.h" | ||
19 | +#include "hw/core/split-irq.h" | ||
20 | #include "hw/sysbus.h" | ||
21 | #include "hw/sd/sd.h" | ||
22 | #include "hw/ssi/ssi.h" | ||
23 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
24 | DeviceState *ssddev; | ||
25 | DriveInfo *dinfo; | ||
26 | DeviceState *carddev; | ||
27 | + DeviceState *gpio_d_splitter; | ||
28 | BlockBackend *blk; | ||
29 | |||
30 | /* | ||
31 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) | ||
32 | &error_fatal); | ||
33 | |||
34 | ssddev = ssi_create_peripheral(bus, "ssd0323"); | ||
35 | - gpio_out[GPIO_D][0] = qemu_irq_split( | ||
36 | - qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0), | ||
37 | + | ||
38 | + gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ); | ||
39 | + qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2); | ||
40 | + qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal); | ||
41 | + qdev_connect_gpio_out( | ||
42 | + gpio_d_splitter, 0, | ||
43 | + qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0)); | ||
44 | + qdev_connect_gpio_out( | ||
45 | + gpio_d_splitter, 1, | ||
46 | qdev_get_gpio_in_named(ssddev, SSI_GPIO_CS, 0)); | ||
47 | + gpio_out[GPIO_D][0] = qdev_get_gpio_in(gpio_d_splitter, 0); | ||
48 | + | ||
49 | gpio_out[GPIO_C][7] = qdev_get_gpio_in(ssddev, 0); | ||
50 | |||
51 | /* Make sure the select pin is high. */ | ||
52 | -- | ||
53 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zongyuan Li <zongyuan.li@smartx.com> | ||
2 | 1 | ||
3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: 20220324181557.203805-5-zongyuan.li@smartx.com | ||
6 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/811 | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
8 | --- | ||
9 | include/hw/irq.h | 5 ----- | ||
10 | hw/core/irq.c | 15 --------------- | ||
11 | 2 files changed, 20 deletions(-) | ||
12 | |||
13 | diff --git a/include/hw/irq.h b/include/hw/irq.h | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/include/hw/irq.h | ||
16 | +++ b/include/hw/irq.h | ||
17 | @@ -XXX,XX +XXX,XX @@ void qemu_free_irq(qemu_irq irq); | ||
18 | /* Returns a new IRQ with opposite polarity. */ | ||
19 | qemu_irq qemu_irq_invert(qemu_irq irq); | ||
20 | |||
21 | -/* Returns a new IRQ which feeds into both the passed IRQs. | ||
22 | - * It's probably better to use the TYPE_SPLIT_IRQ device instead. | ||
23 | - */ | ||
24 | -qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2); | ||
25 | - | ||
26 | /* For internal use in qtest. Similar to qemu_irq_split, but operating | ||
27 | on an existing vector of qemu_irq. */ | ||
28 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n); | ||
29 | diff --git a/hw/core/irq.c b/hw/core/irq.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/hw/core/irq.c | ||
32 | +++ b/hw/core/irq.c | ||
33 | @@ -XXX,XX +XXX,XX @@ qemu_irq qemu_irq_invert(qemu_irq irq) | ||
34 | return qemu_allocate_irq(qemu_notirq, irq, 0); | ||
35 | } | ||
36 | |||
37 | -static void qemu_splitirq(void *opaque, int line, int level) | ||
38 | -{ | ||
39 | - struct IRQState **irq = opaque; | ||
40 | - irq[0]->handler(irq[0]->opaque, irq[0]->n, level); | ||
41 | - irq[1]->handler(irq[1]->opaque, irq[1]->n, level); | ||
42 | -} | ||
43 | - | ||
44 | -qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2) | ||
45 | -{ | ||
46 | - qemu_irq *s = g_new0(qemu_irq, 2); | ||
47 | - s[0] = irq1; | ||
48 | - s[1] = irq2; | ||
49 | - return qemu_allocate_irq(qemu_splitirq, s, 0); | ||
50 | -} | ||
51 | - | ||
52 | void qemu_irq_intercept_in(qemu_irq *gpio_in, qemu_irq_handler handler, int n) | ||
53 | { | ||
54 | int i; | ||
55 | -- | ||
56 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | ||
2 | 1 | ||
3 | Describe that the gic-version influences the maximum number of CPUs. | ||
4 | |||
5 | Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> | ||
6 | Message-id: 20220413231456.35811-1-heinrich.schuchardt@canonical.com | ||
7 | [PMM: minor punctuation tweaks] | ||
8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | docs/system/arm/virt.rst | 4 ++-- | ||
12 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
13 | |||
14 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst | ||
15 | index XXXXXXX..XXXXXXX 100644 | ||
16 | --- a/docs/system/arm/virt.rst | ||
17 | +++ b/docs/system/arm/virt.rst | ||
18 | @@ -XXX,XX +XXX,XX @@ gic-version | ||
19 | Valid values are: | ||
20 | |||
21 | ``2`` | ||
22 | - GICv2 | ||
23 | + GICv2. Note that this limits the number of CPUs to 8. | ||
24 | ``3`` | ||
25 | - GICv3 | ||
26 | + GICv3. This allows up to 512 CPUs. | ||
27 | ``host`` | ||
28 | Use the same GIC version the host provides, when using KVM | ||
29 | ``max`` | ||
30 | -- | ||
31 | 2.25.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Hao Wu <wuhaotsh@google.com> | ||
2 | 1 | ||
3 | Similar to the Aspeed code in include/misc/aspeed_scu.h, we define | ||
4 | the PWRON STRAP fields in their corresponding module for NPCM7XX. | ||
5 | |||
6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> | ||
7 | Reviewed-by: Patrick Venture <venture@google.com> | ||
8 | Message-id: 20220411165842.3912945-2-wuhaotsh@google.com | ||
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | --- | ||
12 | include/hw/misc/npcm7xx_gcr.h | 30 ++++++++++++++++++++++++++++++ | ||
13 | 1 file changed, 30 insertions(+) | ||
14 | |||
15 | diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/include/hw/misc/npcm7xx_gcr.h | ||
18 | +++ b/include/hw/misc/npcm7xx_gcr.h | ||
19 | @@ -XXX,XX +XXX,XX @@ | ||
20 | #include "exec/memory.h" | ||
21 | #include "hw/sysbus.h" | ||
22 | |||
23 | +/* | ||
24 | + * NPCM7XX PWRON STRAP bit fields | ||
25 | + * 12: SPI0 powered by VSBV3 at 1.8V | ||
26 | + * 11: System flash attached to BMC | ||
27 | + * 10: BSP alternative pins. | ||
28 | + * 9:8: Flash UART command route enabled. | ||
29 | + * 7: Security enabled. | ||
30 | + * 6: HI-Z state control. | ||
31 | + * 5: ECC disabled. | ||
32 | + * 4: Reserved | ||
33 | + * 3: JTAG2 enabled. | ||
34 | + * 2:0: CPU and DRAM clock frequency. | ||
35 | + */ | ||
36 | +#define NPCM7XX_PWRON_STRAP_SPI0F18 BIT(12) | ||
37 | +#define NPCM7XX_PWRON_STRAP_SFAB BIT(11) | ||
38 | +#define NPCM7XX_PWRON_STRAP_BSPA BIT(10) | ||
39 | +#define NPCM7XX_PWRON_STRAP_FUP(x) ((x) << 8) | ||
40 | +#define FUP_NORM_UART2 3 | ||
41 | +#define FUP_PROG_UART3 2 | ||
42 | +#define FUP_PROG_UART2 1 | ||
43 | +#define FUP_NORM_UART3 0 | ||
44 | +#define NPCM7XX_PWRON_STRAP_SECEN BIT(7) | ||
45 | +#define NPCM7XX_PWRON_STRAP_HIZ BIT(6) | ||
46 | +#define NPCM7XX_PWRON_STRAP_ECC BIT(5) | ||
47 | +#define NPCM7XX_PWRON_STRAP_RESERVE1 BIT(4) | ||
48 | +#define NPCM7XX_PWRON_STRAP_J2EN BIT(3) | ||
49 | +#define NPCM7XX_PWRON_STRAP_CKFRQ(x) (x) | ||
50 | +#define CKFRQ_SKIPINIT 0x000 | ||
51 | +#define CKFRQ_DEFAULT 0x111 | ||
52 | + | ||
53 | /* | ||
54 | * Number of registers in our device state structure. Don't change this without | ||
55 | * incrementing the version_id in the vmstate. | ||
56 | -- | ||
57 | 2.25.1 | diff view generated by jsdifflib |