1 | Latest arm queue, a mixed bag of features and bug fixes. | 1 | First arm pullreq for 7.1. The bulk of this is the qemu_split_irq |
---|---|---|---|
2 | removal. | ||
3 | |||
4 | I have enough stuff in my to-review queue that I expect to do another | ||
5 | pullreq early next week, but 31 patches is enough to not hang on to. | ||
2 | 6 | ||
3 | thanks | 7 | thanks |
4 | -- PMM | 8 | -- PMM |
5 | 9 | ||
6 | The following changes since commit cbf01142b2aef0c0b4e995cecd7e79d342bbc47e: | 10 | The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b: |
7 | 11 | ||
8 | Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20200115' into staging (2020-01-17 12:13:17 +0000) | 12 | Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700) |
9 | 13 | ||
10 | are available in the Git repository at: | 14 | are available in the Git repository at: |
11 | 15 | ||
12 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20200117-1 | 16 | https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20220421 |
13 | 17 | ||
14 | for you to fetch changes up to 1a1fbc6cbb34c26d43d8360c66c1d21681af14a9: | 18 | for you to fetch changes up to 5b415dd61bdbf61fb4be0e9f1a7172b8bce682c6: |
15 | 19 | ||
16 | target/arm: Set ISSIs16Bit in make_issinfo (2020-01-17 14:27:16 +0000) | 20 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs (2022-04-21 11:37:05 +0100) |
17 | 21 | ||
18 | ---------------------------------------------------------------- | 22 | ---------------------------------------------------------------- |
19 | Add model of the Netduino Plus 2 board | 23 | target-arm queue: |
20 | Some allwinner-a10 code cleanup | 24 | * hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF |
21 | New test cases for cubieboard | 25 | * versal: Add the Cortex-R5s in the Real-Time Processing Unit (RPU) subsystem |
22 | target/arm/arm-semi: fix SYS_OPEN to return nonzero filehandle | 26 | * versal: model enough of the Clock/Reset Low-power domain (CRL) to allow control of the Cortex-R5s |
23 | i.MX: add an emulation for RNGC device | 27 | * xlnx-zynqmp: Connect 4 TTC timers |
24 | target/arm: adjust program counter for wfi exception in AArch32 | 28 | * exynos4210: Refactor GIC/combiner code to stop using qemu_split_irq |
25 | arm/gicv3: update virtual irq state after IAR register read | 29 | * realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
26 | Set IL bit correctly for syndrome information for data aborts | 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 | ||
27 | 34 | ||
28 | ---------------------------------------------------------------- | 35 | ---------------------------------------------------------------- |
29 | Alistair Francis (4): | 36 | Edgar E. Iglesias (6): |
30 | hw/misc: Add the STM32F4xx Sysconfig device | 37 | timer: cadence_ttc: Break out header file to allow embedding |
31 | hw/misc: Add the STM32F4xx EXTI device | 38 | hw/arm/xlnx-zynqmp: Connect 4 TTC timers |
32 | hw/arm: Add the STM32F4xx SoC | 39 | hw/arm: versal: Create an APU CPU Cluster |
33 | hw/arm: Add the Netduino Plus 2 | 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 | ||
34 | 43 | ||
35 | Jeff Kubascik (3): | 44 | Hao Wu (2): |
36 | target/arm: adjust program counter for wfi exception in AArch32 | 45 | hw/misc: Add PWRON STRAP bit fields in GCR module |
37 | arm/gicv3: update virtual irq state after IAR register read | 46 | hw/arm: Use bit fields for NPCM7XX PWRON STRAPs |
38 | target/arm: Return correct IL bit in merge_syn_data_abort | ||
39 | 47 | ||
40 | Martin Kaiser (1): | 48 | Heinrich Schuchardt (1): |
41 | i.MX: add an emulation for RNGC | 49 | hw/arm/virt: impact of gic-version on max CPUs |
42 | 50 | ||
43 | Masahiro Yamada (1): | 51 | Peter Maydell (19): |
44 | target/arm/arm-semi: fix SYS_OPEN to return nonzero filehandle | 52 | hw/arm/virt: Check for attempt to use TrustZone with KVM or HVF |
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 | ||
45 | 71 | ||
46 | Philippe Mathieu-Daudé (5): | 72 | Zongyuan Li (3): |
47 | tests/boot_linux_console: Add initrd test for the CubieBoard | 73 | hw/arm/realview: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
48 | tests/boot_linux_console: Add a SD card test for the CubieBoard | 74 | hw/arm/stellaris: replace 'qemu_split_irq' with 'TYPE_SPLIT_IRQ' |
49 | hw/arm/allwinner-a10: Move SoC definitions out of header | 75 | hw/core/irq: remove unused 'qemu_irq_split' function |
50 | hw/arm/allwinner-a10: Simplify by passing IRQs with qdev_pass_gpios() | ||
51 | hw/arm/allwinner-a10: Remove local qemu_irq variables | ||
52 | 76 | ||
53 | Richard Henderson (1): | 77 | docs/system/arm/virt.rst | 4 +- |
54 | target/arm: Set ISSIs16Bit in make_issinfo | 78 | include/hw/arm/exynos4210.h | 50 ++-- |
55 | 79 | include/hw/arm/xlnx-versal.h | 16 ++ | |
56 | hw/arm/Makefile.objs | 2 + | 80 | include/hw/arm/xlnx-zynqmp.h | 4 + |
57 | hw/misc/Makefile.objs | 3 + | 81 | include/hw/intc/exynos4210_combiner.h | 57 +++++ |
58 | include/hw/arm/allwinner-a10.h | 7 - | 82 | include/hw/intc/exynos4210_gic.h | 43 ++++ |
59 | include/hw/arm/fsl-imx25.h | 5 + | 83 | include/hw/irq.h | 5 - |
60 | include/hw/arm/stm32f405_soc.h | 73 ++++++++ | 84 | include/hw/misc/npcm7xx_gcr.h | 30 +++ |
61 | include/hw/misc/imx_rngc.h | 35 ++++ | 85 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++++ |
62 | include/hw/misc/stm32f4xx_exti.h | 60 +++++++ | 86 | include/hw/timer/cadence_ttc.h | 54 +++++ |
63 | include/hw/misc/stm32f4xx_syscfg.h | 61 +++++++ | 87 | hw/arm/exynos4210.c | 430 ++++++++++++++++++++++++++++++---- |
64 | hw/arm/allwinner-a10.c | 39 +++-- | 88 | hw/arm/npcm7xx_boards.c | 24 +- |
65 | hw/arm/fsl-imx25.c | 11 ++ | 89 | hw/arm/realview.c | 33 ++- |
66 | hw/arm/netduinoplus2.c | 52 ++++++ | 90 | hw/arm/stellaris.c | 15 +- |
67 | hw/arm/stm32f405_soc.c | 302 +++++++++++++++++++++++++++++++++ | 91 | hw/arm/virt.c | 7 + |
68 | hw/intc/arm_gicv3_cpuif.c | 3 + | 92 | hw/arm/xlnx-versal-virt.c | 6 +- |
69 | hw/misc/imx_rngc.c | 278 ++++++++++++++++++++++++++++++ | 93 | hw/arm/xlnx-versal.c | 99 +++++++- |
70 | hw/misc/stm32f4xx_exti.c | 188 ++++++++++++++++++++ | 94 | hw/arm/xlnx-zynqmp.c | 22 ++ |
71 | hw/misc/stm32f4xx_syscfg.c | 171 +++++++++++++++++++ | 95 | hw/core/irq.c | 15 -- |
72 | target/arm/arm-semi.c | 5 +- | 96 | hw/intc/exynos4210_combiner.c | 108 +-------- |
73 | target/arm/op_helper.c | 7 +- | 97 | hw/intc/exynos4210_gic.c | 344 +-------------------------- |
74 | target/arm/tlb_helper.c | 2 +- | 98 | hw/misc/xlnx-versal-crl.c | 421 +++++++++++++++++++++++++++++++++ |
75 | target/arm/translate.c | 3 + | 99 | hw/timer/cadence_ttc.c | 32 +-- |
76 | MAINTAINERS | 14 ++ | 100 | MAINTAINERS | 2 +- |
77 | default-configs/arm-softmmu.mak | 1 + | 101 | hw/misc/meson.build | 1 + |
78 | hw/arm/Kconfig | 10 ++ | 102 | 25 files changed, 1457 insertions(+), 600 deletions(-) |
79 | hw/misc/Kconfig | 6 + | 103 | create mode 100644 include/hw/intc/exynos4210_combiner.h |
80 | hw/misc/trace-events | 11 ++ | 104 | create mode 100644 include/hw/intc/exynos4210_gic.h |
81 | tests/acceptance/boot_linux_console.py | 85 ++++++++++ | 105 | create mode 100644 include/hw/misc/xlnx-versal-crl.h |
82 | 26 files changed, 1405 insertions(+), 29 deletions(-) | 106 | create mode 100644 include/hw/timer/cadence_ttc.h |
83 | create mode 100644 include/hw/arm/stm32f405_soc.h | 107 | create mode 100644 hw/misc/xlnx-versal-crl.c |
84 | create mode 100644 include/hw/misc/imx_rngc.h | ||
85 | create mode 100644 include/hw/misc/stm32f4xx_exti.h | ||
86 | create mode 100644 include/hw/misc/stm32f4xx_syscfg.h | ||
87 | create mode 100644 hw/arm/netduinoplus2.c | ||
88 | create mode 100644 hw/arm/stm32f405_soc.c | ||
89 | create mode 100644 hw/misc/imx_rngc.c | ||
90 | create mode 100644 hw/misc/stm32f4xx_exti.c | ||
91 | create mode 100644 hw/misc/stm32f4xx_syscfg.c | ||
92 | diff view generated by jsdifflib |
New 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: | ||
1 | 6 | ||
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 | From: Alistair Francis <alistair@alistair23.me> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alistair Francis <alistair@alistair23.me> | 3 | Break out header file to allow embedding of the the TTC. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | |
5 | Message-id: 49b01423a09cef2ca832ff73a84a996568f1a8fc.1576658572.git.alistair@alistair23.me | 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-2-edgar.iglesias@gmail.com | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 11 | --- |
8 | hw/misc/Makefile.objs | 1 + | 12 | include/hw/timer/cadence_ttc.h | 54 ++++++++++++++++++++++++++++++++++ |
9 | include/hw/misc/stm32f4xx_syscfg.h | 61 ++++++++++ | 13 | hw/timer/cadence_ttc.c | 32 ++------------------ |
10 | hw/misc/stm32f4xx_syscfg.c | 171 +++++++++++++++++++++++++++++ | 14 | 2 files changed, 56 insertions(+), 30 deletions(-) |
11 | default-configs/arm-softmmu.mak | 1 + | 15 | create mode 100644 include/hw/timer/cadence_ttc.h |
12 | hw/arm/Kconfig | 9 ++ | ||
13 | hw/misc/Kconfig | 3 + | ||
14 | hw/misc/trace-events | 6 + | ||
15 | 7 files changed, 252 insertions(+) | ||
16 | create mode 100644 include/hw/misc/stm32f4xx_syscfg.h | ||
17 | create mode 100644 hw/misc/stm32f4xx_syscfg.c | ||
18 | 16 | ||
19 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | 17 | diff --git a/include/hw/timer/cadence_ttc.h b/include/hw/timer/cadence_ttc.h |
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/misc/Makefile.objs | ||
22 | +++ b/hw/misc/Makefile.objs | ||
23 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_SLAVIO) += slavio_misc.o | ||
24 | common-obj-$(CONFIG_ZYNQ) += zynq_slcr.o | ||
25 | common-obj-$(CONFIG_ZYNQ) += zynq-xadc.o | ||
26 | common-obj-$(CONFIG_STM32F2XX_SYSCFG) += stm32f2xx_syscfg.o | ||
27 | +common-obj-$(CONFIG_STM32F4XX_SYSCFG) += stm32f4xx_syscfg.o | ||
28 | obj-$(CONFIG_MIPS_CPS) += mips_cmgcr.o | ||
29 | obj-$(CONFIG_MIPS_CPS) += mips_cpc.o | ||
30 | obj-$(CONFIG_MIPS_ITU) += mips_itu.o | ||
31 | diff --git a/include/hw/misc/stm32f4xx_syscfg.h b/include/hw/misc/stm32f4xx_syscfg.h | ||
32 | new file mode 100644 | 18 | new file mode 100644 |
33 | index XXXXXXX..XXXXXXX | 19 | index XXXXXXX..XXXXXXX |
34 | --- /dev/null | 20 | --- /dev/null |
35 | +++ b/include/hw/misc/stm32f4xx_syscfg.h | 21 | +++ b/include/hw/timer/cadence_ttc.h |
36 | @@ -XXX,XX +XXX,XX @@ | 22 | @@ -XXX,XX +XXX,XX @@ |
37 | +/* | 23 | +/* |
38 | + * STM32F4xx SYSCFG | 24 | + * Xilinx Zynq cadence TTC model |
39 | + * | 25 | + * |
40 | + * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> | 26 | + * Copyright (c) 2011 Xilinx Inc. |
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 | ||
41 | + * | 31 | + * |
42 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | 32 | + * This program is free software; you can redistribute it and/or |
43 | + * of this software and associated documentation files (the "Software"), to deal | 33 | + * modify it under the terms of the GNU General Public License |
44 | + * in the Software without restriction, including without limitation the rights | 34 | + * as published by the Free Software Foundation; either version |
45 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 35 | + * 2 of the License, or (at your option) any later version. |
46 | + * copies of the Software, and to permit persons to whom the Software is | ||
47 | + * furnished to do so, subject to the following conditions: | ||
48 | + * | 36 | + * |
49 | + * The above copyright notice and this permission notice shall be included in | 37 | + * You should have received a copy of the GNU General Public License along |
50 | + * all copies or substantial portions of the Software. | 38 | + * with this program; if not, see <http://www.gnu.org/licenses/>. |
51 | + * | ||
52 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
53 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
54 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
55 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
56 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
57 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
58 | + * THE SOFTWARE. | ||
59 | + */ | 39 | + */ |
60 | + | 40 | +#ifndef HW_TIMER_CADENCE_TTC_H |
61 | +#ifndef HW_STM_SYSCFG_H | 41 | +#define HW_TIMER_CADENCE_TTC_H |
62 | +#define HW_STM_SYSCFG_H | ||
63 | + | 42 | + |
64 | +#include "hw/sysbus.h" | 43 | +#include "hw/sysbus.h" |
65 | +#include "hw/hw.h" | 44 | +#include "qemu/timer.h" |
66 | + | ||
67 | +#define SYSCFG_MEMRMP 0x00 | ||
68 | +#define SYSCFG_PMC 0x04 | ||
69 | +#define SYSCFG_EXTICR1 0x08 | ||
70 | +#define SYSCFG_EXTICR2 0x0C | ||
71 | +#define SYSCFG_EXTICR3 0x10 | ||
72 | +#define SYSCFG_EXTICR4 0x14 | ||
73 | +#define SYSCFG_CMPCR 0x20 | ||
74 | + | ||
75 | +#define TYPE_STM32F4XX_SYSCFG "stm32f4xx-syscfg" | ||
76 | +#define STM32F4XX_SYSCFG(obj) \ | ||
77 | + OBJECT_CHECK(STM32F4xxSyscfgState, (obj), TYPE_STM32F4XX_SYSCFG) | ||
78 | + | ||
79 | +#define SYSCFG_NUM_EXTICR 4 | ||
80 | + | 45 | + |
81 | +typedef struct { | 46 | +typedef struct { |
82 | + /* <private> */ | 47 | + QEMUTimer *timer; |
48 | + int freq; | ||
49 | + | ||
50 | + uint32_t reg_clock; | ||
51 | + uint32_t reg_count; | ||
52 | + uint32_t reg_value; | ||
53 | + uint16_t reg_interval; | ||
54 | + uint16_t reg_match[3]; | ||
55 | + uint32_t reg_intr; | ||
56 | + uint32_t reg_intr_en; | ||
57 | + uint32_t reg_event_ctrl; | ||
58 | + uint32_t reg_event; | ||
59 | + | ||
60 | + uint64_t cpu_time; | ||
61 | + unsigned int cpu_time_valid; | ||
62 | + | ||
63 | + qemu_irq irq; | ||
64 | +} CadenceTimerState; | ||
65 | + | ||
66 | +#define TYPE_CADENCE_TTC "cadence_ttc" | ||
67 | +OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC) | ||
68 | + | ||
69 | +struct CadenceTTCState { | ||
83 | + SysBusDevice parent_obj; | 70 | + SysBusDevice parent_obj; |
84 | + | 71 | + |
85 | + /* <public> */ | 72 | + MemoryRegion iomem; |
86 | + MemoryRegion mmio; | 73 | + CadenceTimerState timer[3]; |
87 | + | 74 | +}; |
88 | + uint32_t syscfg_memrmp; | ||
89 | + uint32_t syscfg_pmc; | ||
90 | + uint32_t syscfg_exticr[SYSCFG_NUM_EXTICR]; | ||
91 | + uint32_t syscfg_cmpcr; | ||
92 | + | ||
93 | + qemu_irq irq; | ||
94 | + qemu_irq gpio_out[16]; | ||
95 | +} STM32F4xxSyscfgState; | ||
96 | + | 75 | + |
97 | +#endif | 76 | +#endif |
98 | diff --git a/hw/misc/stm32f4xx_syscfg.c b/hw/misc/stm32f4xx_syscfg.c | 77 | diff --git a/hw/timer/cadence_ttc.c b/hw/timer/cadence_ttc.c |
99 | new file mode 100644 | 78 | index XXXXXXX..XXXXXXX 100644 |
100 | index XXXXXXX..XXXXXXX | 79 | --- a/hw/timer/cadence_ttc.c |
101 | --- /dev/null | 80 | +++ b/hw/timer/cadence_ttc.c |
102 | +++ b/hw/misc/stm32f4xx_syscfg.c | ||
103 | @@ -XXX,XX +XXX,XX @@ | 81 | @@ -XXX,XX +XXX,XX @@ |
104 | +/* | 82 | #include "qemu/timer.h" |
105 | + * STM32F4xx SYSCFG | 83 | #include "qom/object.h" |
106 | + * | 84 | |
107 | + * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> | 85 | +#include "hw/timer/cadence_ttc.h" |
108 | + * | ||
109 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
110 | + * of this software and associated documentation files (the "Software"), to deal | ||
111 | + * in the Software without restriction, including without limitation the rights | ||
112 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
113 | + * copies of the Software, and to permit persons to whom the Software is | ||
114 | + * furnished to do so, subject to the following conditions: | ||
115 | + * | ||
116 | + * The above copyright notice and this permission notice shall be included in | ||
117 | + * all copies or substantial portions of the Software. | ||
118 | + * | ||
119 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
120 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
121 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
122 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
123 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
124 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
125 | + * THE SOFTWARE. | ||
126 | + */ | ||
127 | + | 86 | + |
128 | +#include "qemu/osdep.h" | 87 | #ifdef CADENCE_TTC_ERR_DEBUG |
129 | +#include "qemu/log.h" | 88 | #define DB_PRINT(...) do { \ |
130 | +#include "trace.h" | 89 | fprintf(stderr, ": %s: ", __func__); \ |
131 | +#include "hw/irq.h" | 90 | @@ -XXX,XX +XXX,XX @@ |
132 | +#include "migration/vmstate.h" | 91 | #define CLOCK_CTRL_PS_EN 0x00000001 |
133 | +#include "hw/misc/stm32f4xx_syscfg.h" | 92 | #define CLOCK_CTRL_PS_V 0x0000001e |
134 | + | 93 | |
135 | +static void stm32f4xx_syscfg_reset(DeviceState *dev) | 94 | -typedef struct { |
136 | +{ | 95 | - QEMUTimer *timer; |
137 | + STM32F4xxSyscfgState *s = STM32F4XX_SYSCFG(dev); | 96 | - int freq; |
138 | + | 97 | - |
139 | + s->syscfg_memrmp = 0x00000000; | 98 | - uint32_t reg_clock; |
140 | + s->syscfg_pmc = 0x00000000; | 99 | - uint32_t reg_count; |
141 | + s->syscfg_exticr[0] = 0x00000000; | 100 | - uint32_t reg_value; |
142 | + s->syscfg_exticr[1] = 0x00000000; | 101 | - uint16_t reg_interval; |
143 | + s->syscfg_exticr[2] = 0x00000000; | 102 | - uint16_t reg_match[3]; |
144 | + s->syscfg_exticr[3] = 0x00000000; | 103 | - uint32_t reg_intr; |
145 | + s->syscfg_cmpcr = 0x00000000; | 104 | - uint32_t reg_intr_en; |
146 | +} | 105 | - uint32_t reg_event_ctrl; |
147 | + | 106 | - uint32_t reg_event; |
148 | +static void stm32f4xx_syscfg_set_irq(void *opaque, int irq, int level) | 107 | - |
149 | +{ | 108 | - uint64_t cpu_time; |
150 | + STM32F4xxSyscfgState *s = opaque; | 109 | - unsigned int cpu_time_valid; |
151 | + int icrreg = irq / 4; | 110 | - |
152 | + int startbit = (irq & 3) * 4; | 111 | - qemu_irq irq; |
153 | + uint8_t config = config = irq / 16; | 112 | -} CadenceTimerState; |
154 | + | 113 | - |
155 | + trace_stm32f4xx_syscfg_set_irq(irq / 16, irq % 16, level); | 114 | -#define TYPE_CADENCE_TTC "cadence_ttc" |
156 | + | 115 | -OBJECT_DECLARE_SIMPLE_TYPE(CadenceTTCState, CADENCE_TTC) |
157 | + g_assert(icrreg < SYSCFG_NUM_EXTICR); | 116 | - |
158 | + | 117 | -struct CadenceTTCState { |
159 | + if (extract32(s->syscfg_exticr[icrreg], startbit, 4) == config) { | 118 | - SysBusDevice parent_obj; |
160 | + qemu_set_irq(s->gpio_out[irq], level); | 119 | - |
161 | + trace_stm32f4xx_pulse_exti(irq); | 120 | - MemoryRegion iomem; |
162 | + } | 121 | - CadenceTimerState timer[3]; |
163 | +} | 122 | -}; |
164 | + | 123 | - |
165 | +static uint64_t stm32f4xx_syscfg_read(void *opaque, hwaddr addr, | 124 | static void cadence_timer_update(CadenceTimerState *s) |
166 | + unsigned int size) | 125 | { |
167 | +{ | 126 | qemu_set_irq(s->irq, !!(s->reg_intr & s->reg_intr_en)); |
168 | + STM32F4xxSyscfgState *s = opaque; | ||
169 | + | ||
170 | + trace_stm32f4xx_syscfg_read(addr); | ||
171 | + | ||
172 | + switch (addr) { | ||
173 | + case SYSCFG_MEMRMP: | ||
174 | + return s->syscfg_memrmp; | ||
175 | + case SYSCFG_PMC: | ||
176 | + return s->syscfg_pmc; | ||
177 | + case SYSCFG_EXTICR1...SYSCFG_EXTICR4: | ||
178 | + return s->syscfg_exticr[addr / 4 - SYSCFG_EXTICR1 / 4]; | ||
179 | + case SYSCFG_CMPCR: | ||
180 | + return s->syscfg_cmpcr; | ||
181 | + default: | ||
182 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
183 | + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); | ||
184 | + return 0; | ||
185 | + } | ||
186 | +} | ||
187 | + | ||
188 | +static void stm32f4xx_syscfg_write(void *opaque, hwaddr addr, | ||
189 | + uint64_t val64, unsigned int size) | ||
190 | +{ | ||
191 | + STM32F4xxSyscfgState *s = opaque; | ||
192 | + uint32_t value = val64; | ||
193 | + | ||
194 | + trace_stm32f4xx_syscfg_write(value, addr); | ||
195 | + | ||
196 | + switch (addr) { | ||
197 | + case SYSCFG_MEMRMP: | ||
198 | + qemu_log_mask(LOG_UNIMP, | ||
199 | + "%s: Changing the memory mapping isn't supported " \ | ||
200 | + "in QEMU\n", __func__); | ||
201 | + return; | ||
202 | + case SYSCFG_PMC: | ||
203 | + qemu_log_mask(LOG_UNIMP, | ||
204 | + "%s: Changing the memory mapping isn't supported " \ | ||
205 | + "in QEMU\n", __func__); | ||
206 | + return; | ||
207 | + case SYSCFG_EXTICR1...SYSCFG_EXTICR4: | ||
208 | + s->syscfg_exticr[addr / 4 - SYSCFG_EXTICR1 / 4] = (value & 0xFFFF); | ||
209 | + return; | ||
210 | + case SYSCFG_CMPCR: | ||
211 | + s->syscfg_cmpcr = value; | ||
212 | + return; | ||
213 | + default: | ||
214 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
215 | + "%s: Bad offset 0x%"HWADDR_PRIx"\n", __func__, addr); | ||
216 | + } | ||
217 | +} | ||
218 | + | ||
219 | +static const MemoryRegionOps stm32f4xx_syscfg_ops = { | ||
220 | + .read = stm32f4xx_syscfg_read, | ||
221 | + .write = stm32f4xx_syscfg_write, | ||
222 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
223 | +}; | ||
224 | + | ||
225 | +static void stm32f4xx_syscfg_init(Object *obj) | ||
226 | +{ | ||
227 | + STM32F4xxSyscfgState *s = STM32F4XX_SYSCFG(obj); | ||
228 | + | ||
229 | + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq); | ||
230 | + | ||
231 | + memory_region_init_io(&s->mmio, obj, &stm32f4xx_syscfg_ops, s, | ||
232 | + TYPE_STM32F4XX_SYSCFG, 0x400); | ||
233 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | ||
234 | + | ||
235 | + qdev_init_gpio_in(DEVICE(obj), stm32f4xx_syscfg_set_irq, 16 * 9); | ||
236 | + qdev_init_gpio_out(DEVICE(obj), s->gpio_out, 16); | ||
237 | +} | ||
238 | + | ||
239 | +static const VMStateDescription vmstate_stm32f4xx_syscfg = { | ||
240 | + .name = TYPE_STM32F4XX_SYSCFG, | ||
241 | + .version_id = 1, | ||
242 | + .minimum_version_id = 1, | ||
243 | + .fields = (VMStateField[]) { | ||
244 | + VMSTATE_UINT32(syscfg_memrmp, STM32F4xxSyscfgState), | ||
245 | + VMSTATE_UINT32(syscfg_pmc, STM32F4xxSyscfgState), | ||
246 | + VMSTATE_UINT32_ARRAY(syscfg_exticr, STM32F4xxSyscfgState, | ||
247 | + SYSCFG_NUM_EXTICR), | ||
248 | + VMSTATE_UINT32(syscfg_cmpcr, STM32F4xxSyscfgState), | ||
249 | + VMSTATE_END_OF_LIST() | ||
250 | + } | ||
251 | +}; | ||
252 | + | ||
253 | +static void stm32f4xx_syscfg_class_init(ObjectClass *klass, void *data) | ||
254 | +{ | ||
255 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
256 | + | ||
257 | + dc->reset = stm32f4xx_syscfg_reset; | ||
258 | + dc->vmsd = &vmstate_stm32f4xx_syscfg; | ||
259 | +} | ||
260 | + | ||
261 | +static const TypeInfo stm32f4xx_syscfg_info = { | ||
262 | + .name = TYPE_STM32F4XX_SYSCFG, | ||
263 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
264 | + .instance_size = sizeof(STM32F4xxSyscfgState), | ||
265 | + .instance_init = stm32f4xx_syscfg_init, | ||
266 | + .class_init = stm32f4xx_syscfg_class_init, | ||
267 | +}; | ||
268 | + | ||
269 | +static void stm32f4xx_syscfg_register_types(void) | ||
270 | +{ | ||
271 | + type_register_static(&stm32f4xx_syscfg_info); | ||
272 | +} | ||
273 | + | ||
274 | +type_init(stm32f4xx_syscfg_register_types) | ||
275 | diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak | ||
276 | index XXXXXXX..XXXXXXX 100644 | ||
277 | --- a/default-configs/arm-softmmu.mak | ||
278 | +++ b/default-configs/arm-softmmu.mak | ||
279 | @@ -XXX,XX +XXX,XX @@ CONFIG_Z2=y | ||
280 | CONFIG_COLLIE=y | ||
281 | CONFIG_ASPEED_SOC=y | ||
282 | CONFIG_NETDUINO2=y | ||
283 | +CONFIG_NETDUINOPLUS2=y | ||
284 | CONFIG_MPS2=y | ||
285 | CONFIG_RASPI=y | ||
286 | CONFIG_DIGIC=y | ||
287 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | ||
288 | index XXXXXXX..XXXXXXX 100644 | ||
289 | --- a/hw/arm/Kconfig | ||
290 | +++ b/hw/arm/Kconfig | ||
291 | @@ -XXX,XX +XXX,XX @@ config NETDUINO2 | ||
292 | bool | ||
293 | select STM32F205_SOC | ||
294 | |||
295 | +config NETDUINOPLUS2 | ||
296 | + bool | ||
297 | + select STM32F405_SOC | ||
298 | + | ||
299 | config NSERIES | ||
300 | bool | ||
301 | select OMAP | ||
302 | @@ -XXX,XX +XXX,XX @@ config STM32F205_SOC | ||
303 | select STM32F2XX_ADC | ||
304 | select STM32F2XX_SPI | ||
305 | |||
306 | +config STM32F405_SOC | ||
307 | + bool | ||
308 | + select ARM_V7M | ||
309 | + select STM32F4XX_SYSCFG | ||
310 | + | ||
311 | config XLNX_ZYNQMP_ARM | ||
312 | bool | ||
313 | select AHCI | ||
314 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig | ||
315 | index XXXXXXX..XXXXXXX 100644 | ||
316 | --- a/hw/misc/Kconfig | ||
317 | +++ b/hw/misc/Kconfig | ||
318 | @@ -XXX,XX +XXX,XX @@ config IMX | ||
319 | config STM32F2XX_SYSCFG | ||
320 | bool | ||
321 | |||
322 | +config STM32F4XX_SYSCFG | ||
323 | + bool | ||
324 | + | ||
325 | config MIPS_ITU | ||
326 | bool | ||
327 | |||
328 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
329 | index XXXXXXX..XXXXXXX 100644 | ||
330 | --- a/hw/misc/trace-events | ||
331 | +++ b/hw/misc/trace-events | ||
332 | @@ -XXX,XX +XXX,XX @@ mos6522_set_sr_int(void) "set sr_int" | ||
333 | mos6522_write(uint64_t addr, uint64_t val) "reg=0x%"PRIx64 " val=0x%"PRIx64 | ||
334 | mos6522_read(uint64_t addr, unsigned val) "reg=0x%"PRIx64 " val=0x%x" | ||
335 | |||
336 | +# stm32f4xx_syscfg | ||
337 | +stm32f4xx_syscfg_set_irq(int gpio, int line, int level) "Interupt: GPIO: %d, Line: %d; Level: %d" | ||
338 | +stm32f4xx_pulse_exti(int irq) "Pulse EXTI: %d" | ||
339 | +stm32f4xx_syscfg_read(uint64_t addr) "reg read: addr: 0x%" PRIx64 " " | ||
340 | +stm32f4xx_syscfg_write(uint64_t addr, uint64_t data) "reg write: addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" | ||
341 | + | ||
342 | # tz-mpc.c | ||
343 | tz_mpc_reg_read(uint32_t offset, uint64_t data, unsigned size) "TZ MPC regs read: offset 0x%x data 0x%" PRIx64 " size %u" | ||
344 | tz_mpc_reg_write(uint32_t offset, uint64_t data, unsigned size) "TZ MPC regs write: offset 0x%x data 0x%" PRIx64 " size %u" | ||
345 | -- | 127 | -- |
346 | 2.20.1 | 128 | 2.25.1 |
347 | |||
348 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
1 | 2 | ||
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 |
New patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
1 | 2 | ||
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 |
New patch | |||
---|---|---|---|
1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> | ||
1 | 2 | ||
3 | Add the Cortex-R5Fs of the Versal RPU (Real-time Processing Unit) | ||
4 | subsystem. | ||
5 | |||
6 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> | ||
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
8 | Message-id: 20220406174303.2022038-3-edgar.iglesias@xilinx.com | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | --- | ||
11 | include/hw/arm/xlnx-versal.h | 10 ++++++++++ | ||
12 | hw/arm/xlnx-versal-virt.c | 6 +++--- | ||
13 | hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++++++++++ | ||
14 | 3 files changed, 49 insertions(+), 3 deletions(-) | ||
15 | |||
16 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/include/hw/arm/xlnx-versal.h | ||
19 | +++ b/include/hw/arm/xlnx-versal.h | ||
20 | @@ -XXX,XX +XXX,XX @@ | ||
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 | } | ||
75 | } | ||
76 | |||
77 | +static void versal_create_rpu_cpus(Versal *s) | ||
78 | +{ | ||
79 | + int i; | ||
80 | + | ||
81 | + object_initialize_child(OBJECT(s), "rpu-cluster", &s->lpd.rpu.cluster, | ||
82 | + TYPE_CPU_CLUSTER); | ||
83 | + qdev_prop_set_uint32(DEVICE(&s->lpd.rpu.cluster), "cluster-id", 1); | ||
84 | + | ||
85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { | ||
86 | + Object *obj; | ||
87 | + | ||
88 | + object_initialize_child(OBJECT(&s->lpd.rpu.cluster), | ||
89 | + "rpu-cpu[*]", &s->lpd.rpu.cpu[i], | ||
90 | + XLNX_VERSAL_RCPU_TYPE); | ||
91 | + obj = OBJECT(&s->lpd.rpu.cpu[i]); | ||
92 | + object_property_set_bool(obj, "start-powered-off", true, | ||
93 | + &error_abort); | ||
94 | + | ||
95 | + object_property_set_int(obj, "mp-affinity", 0x100 | i, &error_abort); | ||
96 | + object_property_set_int(obj, "core-count", ARRAY_SIZE(s->lpd.rpu.cpu), | ||
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 | +} | ||
105 | + | ||
106 | static void versal_create_uarts(Versal *s, qemu_irq *pic) | ||
107 | { | ||
108 | int i; | ||
109 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) | ||
110 | |||
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 | } | ||
124 | |||
125 | static void versal_init(Object *obj) | ||
126 | @@ -XXX,XX +XXX,XX @@ static void versal_init(Object *obj) | ||
127 | Versal *s = XLNX_VERSAL(obj); | ||
128 | |||
129 | memory_region_init(&s->fpd.apu.mr, obj, "mr-apu", UINT64_MAX); | ||
130 | + memory_region_init(&s->lpd.rpu.mr, obj, "mr-rpu", UINT64_MAX); | ||
131 | memory_region_init(&s->mr_ps, obj, "mr-ps-switch", UINT64_MAX); | ||
132 | + memory_region_init_alias(&s->lpd.rpu.mr_ps_alias, OBJECT(s), | ||
133 | + "mr-rpu-ps-alias", &s->mr_ps, 0, UINT64_MAX); | ||
134 | } | ||
135 | |||
136 | static Property versal_properties[] = { | ||
137 | -- | ||
138 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair@alistair23.me> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alistair Francis <alistair@alistair23.me> | 3 | Add a model of the Xilinx Versal CRL. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | |
5 | Message-id: ef941d59fd8658589d34ed432e1d6dfdcf7fb1d0.1576658572.git.alistair@alistair23.me | 5 | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@amd.com> |
6 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | 6 | Reviewed-by: Frederic Konrad <fkonrad@amd.com> |
7 | Reviewed-by: Francisco Iglesias <francisco.iglesias@amd.com> | ||
8 | Message-id: 20220406174303.2022038-4-edgar.iglesias@xilinx.com | ||
7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
8 | --- | 10 | --- |
9 | hw/misc/Makefile.objs | 1 + | 11 | include/hw/misc/xlnx-versal-crl.h | 235 +++++++++++++++++ |
10 | include/hw/misc/stm32f4xx_exti.h | 60 ++++++++++ | 12 | hw/misc/xlnx-versal-crl.c | 421 ++++++++++++++++++++++++++++++ |
11 | hw/misc/stm32f4xx_exti.c | 188 +++++++++++++++++++++++++++++++ | 13 | hw/misc/meson.build | 1 + |
12 | hw/arm/Kconfig | 1 + | 14 | 3 files changed, 657 insertions(+) |
13 | hw/misc/Kconfig | 3 + | 15 | create mode 100644 include/hw/misc/xlnx-versal-crl.h |
14 | hw/misc/trace-events | 5 + | 16 | create mode 100644 hw/misc/xlnx-versal-crl.c |
15 | 6 files changed, 258 insertions(+) | ||
16 | create mode 100644 include/hw/misc/stm32f4xx_exti.h | ||
17 | create mode 100644 hw/misc/stm32f4xx_exti.c | ||
18 | 17 | ||
19 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | 18 | diff --git a/include/hw/misc/xlnx-versal-crl.h b/include/hw/misc/xlnx-versal-crl.h |
20 | index XXXXXXX..XXXXXXX 100644 | ||
21 | --- a/hw/misc/Makefile.objs | ||
22 | +++ b/hw/misc/Makefile.objs | ||
23 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_ZYNQ) += zynq_slcr.o | ||
24 | common-obj-$(CONFIG_ZYNQ) += zynq-xadc.o | ||
25 | common-obj-$(CONFIG_STM32F2XX_SYSCFG) += stm32f2xx_syscfg.o | ||
26 | common-obj-$(CONFIG_STM32F4XX_SYSCFG) += stm32f4xx_syscfg.o | ||
27 | +common-obj-$(CONFIG_STM32F4XX_EXTI) += stm32f4xx_exti.o | ||
28 | obj-$(CONFIG_MIPS_CPS) += mips_cmgcr.o | ||
29 | obj-$(CONFIG_MIPS_CPS) += mips_cpc.o | ||
30 | obj-$(CONFIG_MIPS_ITU) += mips_itu.o | ||
31 | diff --git a/include/hw/misc/stm32f4xx_exti.h b/include/hw/misc/stm32f4xx_exti.h | ||
32 | new file mode 100644 | 19 | new file mode 100644 |
33 | index XXXXXXX..XXXXXXX | 20 | index XXXXXXX..XXXXXXX |
34 | --- /dev/null | 21 | --- /dev/null |
35 | +++ b/include/hw/misc/stm32f4xx_exti.h | 22 | +++ b/include/hw/misc/xlnx-versal-crl.h |
36 | @@ -XXX,XX +XXX,XX @@ | 23 | @@ -XXX,XX +XXX,XX @@ |
37 | +/* | 24 | +/* |
38 | + * STM32F4XX EXTI | 25 | + * QEMU model of the Clock-Reset-LPD (CRL). |
39 | + * | 26 | + * |
40 | + * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> | 27 | + * Copyright (c) 2022 Xilinx Inc. |
28 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
41 | + * | 29 | + * |
42 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | 30 | + * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com> |
43 | + * of this software and associated documentation files (the "Software"), to deal | ||
44 | + * in the Software without restriction, including without limitation the rights | ||
45 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
46 | + * copies of the Software, and to permit persons to whom the Software is | ||
47 | + * furnished to do so, subject to the following conditions: | ||
48 | + * | ||
49 | + * The above copyright notice and this permission notice shall be included in | ||
50 | + * all copies or substantial portions of the Software. | ||
51 | + * | ||
52 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
53 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
54 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
55 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
56 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
57 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
58 | + * THE SOFTWARE. | ||
59 | + */ | 31 | + */ |
60 | + | 32 | +#ifndef HW_MISC_XLNX_VERSAL_CRL_H |
61 | +#ifndef HW_STM_EXTI_H | 33 | +#define HW_MISC_XLNX_VERSAL_CRL_H |
62 | +#define HW_STM_EXTI_H | ||
63 | + | 34 | + |
64 | +#include "hw/sysbus.h" | 35 | +#include "hw/sysbus.h" |
65 | +#include "hw/hw.h" | 36 | +#include "hw/register.h" |
66 | + | 37 | +#include "target/arm/cpu.h" |
67 | +#define EXTI_IMR 0x00 | 38 | + |
68 | +#define EXTI_EMR 0x04 | 39 | +#define TYPE_XLNX_VERSAL_CRL "xlnx,versal-crl" |
69 | +#define EXTI_RTSR 0x08 | 40 | +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCRL, XLNX_VERSAL_CRL) |
70 | +#define EXTI_FTSR 0x0C | 41 | + |
71 | +#define EXTI_SWIER 0x10 | 42 | +REG32(ERR_CTRL, 0x0) |
72 | +#define EXTI_PR 0x14 | 43 | + FIELD(ERR_CTRL, SLVERR_ENABLE, 0, 1) |
73 | + | 44 | +REG32(IR_STATUS, 0x4) |
74 | +#define TYPE_STM32F4XX_EXTI "stm32f4xx-exti" | 45 | + FIELD(IR_STATUS, ADDR_DECODE_ERR, 0, 1) |
75 | +#define STM32F4XX_EXTI(obj) \ | 46 | +REG32(IR_MASK, 0x8) |
76 | + OBJECT_CHECK(STM32F4xxExtiState, (obj), TYPE_STM32F4XX_EXTI) | 47 | + FIELD(IR_MASK, ADDR_DECODE_ERR, 0, 1) |
77 | + | 48 | +REG32(IR_ENABLE, 0xc) |
78 | +#define NUM_GPIO_EVENT_IN_LINES 16 | 49 | + FIELD(IR_ENABLE, ADDR_DECODE_ERR, 0, 1) |
79 | +#define NUM_INTERRUPT_OUT_LINES 16 | 50 | +REG32(IR_DISABLE, 0x10) |
80 | + | 51 | + FIELD(IR_DISABLE, ADDR_DECODE_ERR, 0, 1) |
81 | +typedef struct { | 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 { | ||
82 | + SysBusDevice parent_obj; | 243 | + SysBusDevice parent_obj; |
83 | + | 244 | + qemu_irq irq; |
84 | + MemoryRegion mmio; | 245 | + |
85 | + | 246 | + struct { |
86 | + uint32_t exti_imr; | 247 | + ARMCPU *cpu_r5[RPU_MAX_CPU]; |
87 | + uint32_t exti_emr; | 248 | + DeviceState *adma[8]; |
88 | + uint32_t exti_rtsr; | 249 | + DeviceState *uart[2]; |
89 | + uint32_t exti_ftsr; | 250 | + DeviceState *gem[2]; |
90 | + uint32_t exti_swier; | 251 | + DeviceState *usb; |
91 | + uint32_t exti_pr; | 252 | + } cfg; |
92 | + | 253 | + |
93 | + qemu_irq irq[NUM_INTERRUPT_OUT_LINES]; | 254 | + RegisterInfoArray *reg_array; |
94 | +} STM32F4xxExtiState; | 255 | + uint32_t regs[CRL_R_MAX]; |
95 | + | 256 | + RegisterInfo regs_info[CRL_R_MAX]; |
257 | +}; | ||
96 | +#endif | 258 | +#endif |
97 | diff --git a/hw/misc/stm32f4xx_exti.c b/hw/misc/stm32f4xx_exti.c | 259 | diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c |
98 | new file mode 100644 | 260 | new file mode 100644 |
99 | index XXXXXXX..XXXXXXX | 261 | index XXXXXXX..XXXXXXX |
100 | --- /dev/null | 262 | --- /dev/null |
101 | +++ b/hw/misc/stm32f4xx_exti.c | 263 | +++ b/hw/misc/xlnx-versal-crl.c |
102 | @@ -XXX,XX +XXX,XX @@ | 264 | @@ -XXX,XX +XXX,XX @@ |
103 | +/* | 265 | +/* |
104 | + * STM32F4XX EXTI | 266 | + * QEMU model of the Clock-Reset-LPD (CRL). |
105 | + * | 267 | + * |
106 | + * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> | 268 | + * Copyright (c) 2022 Advanced Micro Devices, Inc. |
269 | + * SPDX-License-Identifier: GPL-2.0-or-later | ||
107 | + * | 270 | + * |
108 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | 271 | + * Written by Edgar E. Iglesias <edgar.iglesias@amd.com> |
109 | + * of this software and associated documentation files (the "Software"), to deal | ||
110 | + * in the Software without restriction, including without limitation the rights | ||
111 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
112 | + * copies of the Software, and to permit persons to whom the Software is | ||
113 | + * furnished to do so, subject to the following conditions: | ||
114 | + * | ||
115 | + * The above copyright notice and this permission notice shall be included in | ||
116 | + * all copies or substantial portions of the Software. | ||
117 | + * | ||
118 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
119 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
120 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
121 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
122 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
123 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
124 | + * THE SOFTWARE. | ||
125 | + */ | 272 | + */ |
126 | + | 273 | + |
127 | +#include "qemu/osdep.h" | 274 | +#include "qemu/osdep.h" |
275 | +#include "qapi/error.h" | ||
128 | +#include "qemu/log.h" | 276 | +#include "qemu/log.h" |
129 | +#include "trace.h" | 277 | +#include "qemu/bitops.h" |
278 | +#include "migration/vmstate.h" | ||
279 | +#include "hw/qdev-properties.h" | ||
280 | +#include "hw/sysbus.h" | ||
130 | +#include "hw/irq.h" | 281 | +#include "hw/irq.h" |
131 | +#include "migration/vmstate.h" | 282 | +#include "hw/register.h" |
132 | +#include "hw/misc/stm32f4xx_exti.h" | 283 | +#include "hw/resettable.h" |
133 | + | 284 | + |
134 | +static void stm32f4xx_exti_reset(DeviceState *dev) | 285 | +#include "target/arm/arm-powerctl.h" |
135 | +{ | 286 | +#include "hw/misc/xlnx-versal-crl.h" |
136 | + STM32F4xxExtiState *s = STM32F4XX_EXTI(dev); | 287 | + |
137 | + | 288 | +#ifndef XLNX_VERSAL_CRL_ERR_DEBUG |
138 | + s->exti_imr = 0x00000000; | 289 | +#define XLNX_VERSAL_CRL_ERR_DEBUG 0 |
139 | + s->exti_emr = 0x00000000; | 290 | +#endif |
140 | + s->exti_rtsr = 0x00000000; | 291 | + |
141 | + s->exti_ftsr = 0x00000000; | 292 | +static void crl_update_irq(XlnxVersalCRL *s) |
142 | + s->exti_swier = 0x00000000; | 293 | +{ |
143 | + s->exti_pr = 0x00000000; | 294 | + bool pending = s->regs[R_IR_STATUS] & ~s->regs[R_IR_MASK]; |
144 | +} | 295 | + qemu_set_irq(s->irq, pending); |
145 | + | 296 | +} |
146 | +static void stm32f4xx_exti_set_irq(void *opaque, int irq, int level) | 297 | + |
147 | +{ | 298 | +static void crl_status_postw(RegisterInfo *reg, uint64_t val64) |
148 | + STM32F4xxExtiState *s = opaque; | 299 | +{ |
149 | + | 300 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); |
150 | + trace_stm32f4xx_exti_set_irq(irq, level); | 301 | + crl_update_irq(s); |
151 | + | 302 | +} |
152 | + if (((1 << irq) & s->exti_rtsr) && level) { | 303 | + |
153 | + /* Rising Edge */ | 304 | +static uint64_t crl_enable_prew(RegisterInfo *reg, uint64_t val64) |
154 | + s->exti_pr |= 1 << irq; | 305 | +{ |
155 | + } | 306 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); |
156 | + | 307 | + uint32_t val = val64; |
157 | + if (((1 << irq) & s->exti_ftsr) && !level) { | 308 | + |
158 | + /* Falling Edge */ | 309 | + s->regs[R_IR_MASK] &= ~val; |
159 | + s->exti_pr |= 1 << irq; | 310 | + crl_update_irq(s); |
160 | + } | ||
161 | + | ||
162 | + if (!((1 << irq) & s->exti_imr)) { | ||
163 | + /* Interrupt is masked */ | ||
164 | + return; | ||
165 | + } | ||
166 | + qemu_irq_pulse(s->irq[irq]); | ||
167 | +} | ||
168 | + | ||
169 | +static uint64_t stm32f4xx_exti_read(void *opaque, hwaddr addr, | ||
170 | + unsigned int size) | ||
171 | +{ | ||
172 | + STM32F4xxExtiState *s = opaque; | ||
173 | + | ||
174 | + trace_stm32f4xx_exti_read(addr); | ||
175 | + | ||
176 | + switch (addr) { | ||
177 | + case EXTI_IMR: | ||
178 | + return s->exti_imr; | ||
179 | + case EXTI_EMR: | ||
180 | + return s->exti_emr; | ||
181 | + case EXTI_RTSR: | ||
182 | + return s->exti_rtsr; | ||
183 | + case EXTI_FTSR: | ||
184 | + return s->exti_ftsr; | ||
185 | + case EXTI_SWIER: | ||
186 | + return s->exti_swier; | ||
187 | + case EXTI_PR: | ||
188 | + return s->exti_pr; | ||
189 | + default: | ||
190 | + qemu_log_mask(LOG_GUEST_ERROR, | ||
191 | + "STM32F4XX_exti_read: Bad offset %x\n", (int)addr); | ||
192 | + return 0; | ||
193 | + } | ||
194 | + return 0; | 311 | + return 0; |
195 | +} | 312 | +} |
196 | + | 313 | + |
197 | +static void stm32f4xx_exti_write(void *opaque, hwaddr addr, | 314 | +static uint64_t crl_disable_prew(RegisterInfo *reg, uint64_t val64) |
198 | + uint64_t val64, unsigned int size) | 315 | +{ |
199 | +{ | 316 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); |
200 | + STM32F4xxExtiState *s = opaque; | 317 | + uint32_t val = val64; |
201 | + uint32_t value = (uint32_t) val64; | 318 | + |
202 | + | 319 | + s->regs[R_IR_MASK] |= val; |
203 | + trace_stm32f4xx_exti_write(addr, value); | 320 | + crl_update_irq(s); |
204 | + | 321 | + return 0; |
205 | + switch (addr) { | 322 | +} |
206 | + case EXTI_IMR: | 323 | + |
207 | + s->exti_imr = value; | 324 | +static void crl_reset_dev(XlnxVersalCRL *s, DeviceState *dev, |
208 | + return; | 325 | + bool rst_old, bool rst_new) |
209 | + case EXTI_EMR: | 326 | +{ |
210 | + s->exti_emr = value; | 327 | + device_cold_reset(dev); |
211 | + return; | 328 | +} |
212 | + case EXTI_RTSR: | 329 | + |
213 | + s->exti_rtsr = value; | 330 | +static void crl_reset_cpu(XlnxVersalCRL *s, ARMCPU *armcpu, |
214 | + return; | 331 | + bool rst_old, bool rst_new) |
215 | + case EXTI_FTSR: | 332 | +{ |
216 | + s->exti_ftsr = value; | 333 | + if (rst_new) { |
217 | + return; | 334 | + arm_set_cpu_off(armcpu->mp_affinity); |
218 | + case EXTI_SWIER: | 335 | + } else { |
219 | + s->exti_swier = value; | 336 | + arm_set_cpu_on_and_reset(armcpu->mp_affinity); |
220 | + return; | 337 | + } |
221 | + case EXTI_PR: | 338 | +} |
222 | + /* This bit is cleared by writing a 1 to it */ | 339 | + |
223 | + s->exti_pr &= ~value; | 340 | +#define REGFIELD_RESET(type, s, reg, f, new_val, dev) { \ |
224 | + return; | 341 | + bool old_f = ARRAY_FIELD_EX32((s)->regs, reg, f); \ |
225 | + default: | 342 | + bool new_f = FIELD_EX32(new_val, reg, f); \ |
226 | + qemu_log_mask(LOG_GUEST_ERROR, | 343 | + \ |
227 | + "STM32F4XX_exti_write: Bad offset %x\n", (int)addr); | 344 | + /* Detect edges. */ \ |
228 | + } | 345 | + if (dev && old_f != new_f) { \ |
229 | +} | 346 | + crl_reset_ ## type(s, dev, old_f, new_f); \ |
230 | + | 347 | + } \ |
231 | +static const MemoryRegionOps stm32f4xx_exti_ops = { | 348 | +} |
232 | + .read = stm32f4xx_exti_read, | 349 | + |
233 | + .write = stm32f4xx_exti_write, | 350 | +static uint64_t crl_rst_r5_prew(RegisterInfo *reg, uint64_t val64) |
234 | + .endianness = DEVICE_NATIVE_ENDIAN, | 351 | +{ |
352 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
353 | + | ||
354 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU0, val64, s->cfg.cpu_r5[0]); | ||
355 | + REGFIELD_RESET(cpu, s, RST_CPU_R5, RESET_CPU1, val64, s->cfg.cpu_r5[1]); | ||
356 | + return val64; | ||
357 | +} | ||
358 | + | ||
359 | +static uint64_t crl_rst_adma_prew(RegisterInfo *reg, uint64_t val64) | ||
360 | +{ | ||
361 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
362 | + int i; | ||
363 | + | ||
364 | + /* A single register fans out to all ADMA reset inputs. */ | ||
365 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); i++) { | ||
366 | + REGFIELD_RESET(dev, s, RST_ADMA, RESET, val64, s->cfg.adma[i]); | ||
367 | + } | ||
368 | + return val64; | ||
369 | +} | ||
370 | + | ||
371 | +static uint64_t crl_rst_uart0_prew(RegisterInfo *reg, uint64_t val64) | ||
372 | +{ | ||
373 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
374 | + | ||
375 | + REGFIELD_RESET(dev, s, RST_UART0, RESET, val64, s->cfg.uart[0]); | ||
376 | + return val64; | ||
377 | +} | ||
378 | + | ||
379 | +static uint64_t crl_rst_uart1_prew(RegisterInfo *reg, uint64_t val64) | ||
380 | +{ | ||
381 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
382 | + | ||
383 | + REGFIELD_RESET(dev, s, RST_UART1, RESET, val64, s->cfg.uart[1]); | ||
384 | + return val64; | ||
385 | +} | ||
386 | + | ||
387 | +static uint64_t crl_rst_gem0_prew(RegisterInfo *reg, uint64_t val64) | ||
388 | +{ | ||
389 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
390 | + | ||
391 | + REGFIELD_RESET(dev, s, RST_GEM0, RESET, val64, s->cfg.gem[0]); | ||
392 | + return val64; | ||
393 | +} | ||
394 | + | ||
395 | +static uint64_t crl_rst_gem1_prew(RegisterInfo *reg, uint64_t val64) | ||
396 | +{ | ||
397 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
398 | + | ||
399 | + REGFIELD_RESET(dev, s, RST_GEM1, RESET, val64, s->cfg.gem[1]); | ||
400 | + return val64; | ||
401 | +} | ||
402 | + | ||
403 | +static uint64_t crl_rst_usb_prew(RegisterInfo *reg, uint64_t val64) | ||
404 | +{ | ||
405 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(reg->opaque); | ||
406 | + | ||
407 | + REGFIELD_RESET(dev, s, RST_USB0, RESET, val64, s->cfg.usb); | ||
408 | + return val64; | ||
409 | +} | ||
410 | + | ||
411 | +static const RegisterAccessInfo crl_regs_info[] = { | ||
412 | + { .name = "ERR_CTRL", .addr = A_ERR_CTRL, | ||
413 | + },{ .name = "IR_STATUS", .addr = A_IR_STATUS, | ||
414 | + .w1c = 0x1, | ||
415 | + .post_write = crl_status_postw, | ||
416 | + },{ .name = "IR_MASK", .addr = A_IR_MASK, | ||
417 | + .reset = 0x1, | ||
418 | + .ro = 0x1, | ||
419 | + },{ .name = "IR_ENABLE", .addr = A_IR_ENABLE, | ||
420 | + .pre_write = crl_enable_prew, | ||
421 | + },{ .name = "IR_DISABLE", .addr = A_IR_DISABLE, | ||
422 | + .pre_write = crl_disable_prew, | ||
423 | + },{ .name = "WPROT", .addr = A_WPROT, | ||
424 | + },{ .name = "PLL_CLK_OTHER_DMN", .addr = A_PLL_CLK_OTHER_DMN, | ||
425 | + .reset = 0x1, | ||
426 | + .rsvd = 0xe, | ||
427 | + },{ .name = "RPLL_CTRL", .addr = A_RPLL_CTRL, | ||
428 | + .reset = 0x24809, | ||
429 | + .rsvd = 0xf88c00f6, | ||
430 | + },{ .name = "RPLL_CFG", .addr = A_RPLL_CFG, | ||
431 | + .reset = 0x2000000, | ||
432 | + .rsvd = 0x1801210, | ||
433 | + },{ .name = "RPLL_FRAC_CFG", .addr = A_RPLL_FRAC_CFG, | ||
434 | + .rsvd = 0x7e330000, | ||
435 | + },{ .name = "PLL_STATUS", .addr = A_PLL_STATUS, | ||
436 | + .reset = R_PLL_STATUS_RPLL_STABLE_MASK | | ||
437 | + R_PLL_STATUS_RPLL_LOCK_MASK, | ||
438 | + .rsvd = 0xfa, | ||
439 | + .ro = 0x5, | ||
440 | + },{ .name = "RPLL_TO_XPD_CTRL", .addr = A_RPLL_TO_XPD_CTRL, | ||
441 | + .reset = 0x2000100, | ||
442 | + .rsvd = 0xfdfc00ff, | ||
443 | + },{ .name = "LPD_TOP_SWITCH_CTRL", .addr = A_LPD_TOP_SWITCH_CTRL, | ||
444 | + .reset = 0x6000300, | ||
445 | + .rsvd = 0xf9fc00f8, | ||
446 | + },{ .name = "LPD_LSBUS_CTRL", .addr = A_LPD_LSBUS_CTRL, | ||
447 | + .reset = 0x2000800, | ||
448 | + .rsvd = 0xfdfc00f8, | ||
449 | + },{ .name = "CPU_R5_CTRL", .addr = A_CPU_R5_CTRL, | ||
450 | + .reset = 0xe000300, | ||
451 | + .rsvd = 0xe1fc00f8, | ||
452 | + },{ .name = "IOU_SWITCH_CTRL", .addr = A_IOU_SWITCH_CTRL, | ||
453 | + .reset = 0x2000500, | ||
454 | + .rsvd = 0xfdfc00f8, | ||
455 | + },{ .name = "GEM0_REF_CTRL", .addr = A_GEM0_REF_CTRL, | ||
456 | + .reset = 0xe000a00, | ||
457 | + .rsvd = 0xf1fc00f8, | ||
458 | + },{ .name = "GEM1_REF_CTRL", .addr = A_GEM1_REF_CTRL, | ||
459 | + .reset = 0xe000a00, | ||
460 | + .rsvd = 0xf1fc00f8, | ||
461 | + },{ .name = "GEM_TSU_REF_CTRL", .addr = A_GEM_TSU_REF_CTRL, | ||
462 | + .reset = 0x300, | ||
463 | + .rsvd = 0xfdfc00f8, | ||
464 | + },{ .name = "USB0_BUS_REF_CTRL", .addr = A_USB0_BUS_REF_CTRL, | ||
465 | + .reset = 0x2001900, | ||
466 | + .rsvd = 0xfdfc00f8, | ||
467 | + },{ .name = "UART0_REF_CTRL", .addr = A_UART0_REF_CTRL, | ||
468 | + .reset = 0xc00, | ||
469 | + .rsvd = 0xfdfc00f8, | ||
470 | + },{ .name = "UART1_REF_CTRL", .addr = A_UART1_REF_CTRL, | ||
471 | + .reset = 0xc00, | ||
472 | + .rsvd = 0xfdfc00f8, | ||
473 | + },{ .name = "SPI0_REF_CTRL", .addr = A_SPI0_REF_CTRL, | ||
474 | + .reset = 0x600, | ||
475 | + .rsvd = 0xfdfc00f8, | ||
476 | + },{ .name = "SPI1_REF_CTRL", .addr = A_SPI1_REF_CTRL, | ||
477 | + .reset = 0x600, | ||
478 | + .rsvd = 0xfdfc00f8, | ||
479 | + },{ .name = "CAN0_REF_CTRL", .addr = A_CAN0_REF_CTRL, | ||
480 | + .reset = 0xc00, | ||
481 | + .rsvd = 0xfdfc00f8, | ||
482 | + },{ .name = "CAN1_REF_CTRL", .addr = A_CAN1_REF_CTRL, | ||
483 | + .reset = 0xc00, | ||
484 | + .rsvd = 0xfdfc00f8, | ||
485 | + },{ .name = "I2C0_REF_CTRL", .addr = A_I2C0_REF_CTRL, | ||
486 | + .reset = 0xc00, | ||
487 | + .rsvd = 0xfdfc00f8, | ||
488 | + },{ .name = "I2C1_REF_CTRL", .addr = A_I2C1_REF_CTRL, | ||
489 | + .reset = 0xc00, | ||
490 | + .rsvd = 0xfdfc00f8, | ||
491 | + },{ .name = "DBG_LPD_CTRL", .addr = A_DBG_LPD_CTRL, | ||
492 | + .reset = 0x300, | ||
493 | + .rsvd = 0xfdfc00f8, | ||
494 | + },{ .name = "TIMESTAMP_REF_CTRL", .addr = A_TIMESTAMP_REF_CTRL, | ||
495 | + .reset = 0x2000c00, | ||
496 | + .rsvd = 0xfdfc00f8, | ||
497 | + },{ .name = "CRL_SAFETY_CHK", .addr = A_CRL_SAFETY_CHK, | ||
498 | + },{ .name = "PSM_REF_CTRL", .addr = A_PSM_REF_CTRL, | ||
499 | + .reset = 0xf04, | ||
500 | + .rsvd = 0xfffc00f8, | ||
501 | + },{ .name = "DBG_TSTMP_CTRL", .addr = A_DBG_TSTMP_CTRL, | ||
502 | + .reset = 0x300, | ||
503 | + .rsvd = 0xfdfc00f8, | ||
504 | + },{ .name = "CPM_TOPSW_REF_CTRL", .addr = A_CPM_TOPSW_REF_CTRL, | ||
505 | + .reset = 0x300, | ||
506 | + .rsvd = 0xfdfc00f8, | ||
507 | + },{ .name = "USB3_DUAL_REF_CTRL", .addr = A_USB3_DUAL_REF_CTRL, | ||
508 | + .reset = 0x3c00, | ||
509 | + .rsvd = 0xfdfc00f8, | ||
510 | + },{ .name = "RST_CPU_R5", .addr = A_RST_CPU_R5, | ||
511 | + .reset = 0x17, | ||
512 | + .rsvd = 0x8, | ||
513 | + .pre_write = crl_rst_r5_prew, | ||
514 | + },{ .name = "RST_ADMA", .addr = A_RST_ADMA, | ||
515 | + .reset = 0x1, | ||
516 | + .pre_write = crl_rst_adma_prew, | ||
517 | + },{ .name = "RST_GEM0", .addr = A_RST_GEM0, | ||
518 | + .reset = 0x1, | ||
519 | + .pre_write = crl_rst_gem0_prew, | ||
520 | + },{ .name = "RST_GEM1", .addr = A_RST_GEM1, | ||
521 | + .reset = 0x1, | ||
522 | + .pre_write = crl_rst_gem1_prew, | ||
523 | + },{ .name = "RST_SPARE", .addr = A_RST_SPARE, | ||
524 | + .reset = 0x1, | ||
525 | + },{ .name = "RST_USB0", .addr = A_RST_USB0, | ||
526 | + .reset = 0x1, | ||
527 | + .pre_write = crl_rst_usb_prew, | ||
528 | + },{ .name = "RST_UART0", .addr = A_RST_UART0, | ||
529 | + .reset = 0x1, | ||
530 | + .pre_write = crl_rst_uart0_prew, | ||
531 | + },{ .name = "RST_UART1", .addr = A_RST_UART1, | ||
532 | + .reset = 0x1, | ||
533 | + .pre_write = crl_rst_uart1_prew, | ||
534 | + },{ .name = "RST_SPI0", .addr = A_RST_SPI0, | ||
535 | + .reset = 0x1, | ||
536 | + },{ .name = "RST_SPI1", .addr = A_RST_SPI1, | ||
537 | + .reset = 0x1, | ||
538 | + },{ .name = "RST_CAN0", .addr = A_RST_CAN0, | ||
539 | + .reset = 0x1, | ||
540 | + },{ .name = "RST_CAN1", .addr = A_RST_CAN1, | ||
541 | + .reset = 0x1, | ||
542 | + },{ .name = "RST_I2C0", .addr = A_RST_I2C0, | ||
543 | + .reset = 0x1, | ||
544 | + },{ .name = "RST_I2C1", .addr = A_RST_I2C1, | ||
545 | + .reset = 0x1, | ||
546 | + },{ .name = "RST_DBG_LPD", .addr = A_RST_DBG_LPD, | ||
547 | + .reset = 0x33, | ||
548 | + .rsvd = 0xcc, | ||
549 | + },{ .name = "RST_GPIO", .addr = A_RST_GPIO, | ||
550 | + .reset = 0x1, | ||
551 | + },{ .name = "RST_TTC", .addr = A_RST_TTC, | ||
552 | + .reset = 0xf, | ||
553 | + },{ .name = "RST_TIMESTAMP", .addr = A_RST_TIMESTAMP, | ||
554 | + .reset = 0x1, | ||
555 | + },{ .name = "RST_SWDT", .addr = A_RST_SWDT, | ||
556 | + .reset = 0x1, | ||
557 | + },{ .name = "RST_OCM", .addr = A_RST_OCM, | ||
558 | + },{ .name = "RST_IPI", .addr = A_RST_IPI, | ||
559 | + },{ .name = "RST_FPD", .addr = A_RST_FPD, | ||
560 | + .reset = 0x3, | ||
561 | + },{ .name = "PSM_RST_MODE", .addr = A_PSM_RST_MODE, | ||
562 | + .reset = 0x1, | ||
563 | + .rsvd = 0xf8, | ||
564 | + } | ||
235 | +}; | 565 | +}; |
236 | + | 566 | + |
237 | +static void stm32f4xx_exti_init(Object *obj) | 567 | +static void crl_reset_enter(Object *obj, ResetType type) |
238 | +{ | 568 | +{ |
239 | + STM32F4xxExtiState *s = STM32F4XX_EXTI(obj); | 569 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); |
570 | + unsigned int i; | ||
571 | + | ||
572 | + for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) { | ||
573 | + register_reset(&s->regs_info[i]); | ||
574 | + } | ||
575 | +} | ||
576 | + | ||
577 | +static void crl_reset_hold(Object *obj) | ||
578 | +{ | ||
579 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
580 | + | ||
581 | + crl_update_irq(s); | ||
582 | +} | ||
583 | + | ||
584 | +static const MemoryRegionOps crl_ops = { | ||
585 | + .read = register_read_memory, | ||
586 | + .write = register_write_memory, | ||
587 | + .endianness = DEVICE_LITTLE_ENDIAN, | ||
588 | + .valid = { | ||
589 | + .min_access_size = 4, | ||
590 | + .max_access_size = 4, | ||
591 | + }, | ||
592 | +}; | ||
593 | + | ||
594 | +static void crl_init(Object *obj) | ||
595 | +{ | ||
596 | + XlnxVersalCRL *s = XLNX_VERSAL_CRL(obj); | ||
597 | + SysBusDevice *sbd = SYS_BUS_DEVICE(obj); | ||
240 | + int i; | 598 | + int i; |
241 | + | 599 | + |
242 | + for (i = 0; i < NUM_INTERRUPT_OUT_LINES; i++) { | 600 | + s->reg_array = |
243 | + sysbus_init_irq(SYS_BUS_DEVICE(obj), &s->irq[i]); | 601 | + register_init_block32(DEVICE(obj), crl_regs_info, |
244 | + } | 602 | + ARRAY_SIZE(crl_regs_info), |
245 | + | 603 | + s->regs_info, s->regs, |
246 | + memory_region_init_io(&s->mmio, obj, &stm32f4xx_exti_ops, s, | 604 | + &crl_ops, |
247 | + TYPE_STM32F4XX_EXTI, 0x400); | 605 | + XLNX_VERSAL_CRL_ERR_DEBUG, |
248 | + sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->mmio); | 606 | + CRL_R_MAX * 4); |
249 | + | 607 | + sysbus_init_mmio(sbd, &s->reg_array->mem); |
250 | + qdev_init_gpio_in(DEVICE(obj), stm32f4xx_exti_set_irq, | 608 | + sysbus_init_irq(sbd, &s->irq); |
251 | + NUM_GPIO_EVENT_IN_LINES); | 609 | + |
252 | +} | 610 | + for (i = 0; i < ARRAY_SIZE(s->cfg.cpu_r5); ++i) { |
253 | + | 611 | + object_property_add_link(obj, "cpu_r5[*]", TYPE_ARM_CPU, |
254 | +static const VMStateDescription vmstate_stm32f4xx_exti = { | 612 | + (Object **)&s->cfg.cpu_r5[i], |
255 | + .name = TYPE_STM32F4XX_EXTI, | 613 | + qdev_prop_allow_set_link_before_realize, |
614 | + OBJ_PROP_LINK_STRONG); | ||
615 | + } | ||
616 | + | ||
617 | + for (i = 0; i < ARRAY_SIZE(s->cfg.adma); ++i) { | ||
618 | + object_property_add_link(obj, "adma[*]", TYPE_DEVICE, | ||
619 | + (Object **)&s->cfg.adma[i], | ||
620 | + qdev_prop_allow_set_link_before_realize, | ||
621 | + OBJ_PROP_LINK_STRONG); | ||
622 | + } | ||
623 | + | ||
624 | + for (i = 0; i < ARRAY_SIZE(s->cfg.uart); ++i) { | ||
625 | + object_property_add_link(obj, "uart[*]", TYPE_DEVICE, | ||
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, | ||
256 | + .version_id = 1, | 652 | + .version_id = 1, |
257 | + .minimum_version_id = 1, | 653 | + .minimum_version_id = 1, |
258 | + .fields = (VMStateField[]) { | 654 | + .fields = (VMStateField[]) { |
259 | + VMSTATE_UINT32(exti_imr, STM32F4xxExtiState), | 655 | + VMSTATE_UINT32_ARRAY(regs, XlnxVersalCRL, CRL_R_MAX), |
260 | + VMSTATE_UINT32(exti_emr, STM32F4xxExtiState), | 656 | + VMSTATE_END_OF_LIST(), |
261 | + VMSTATE_UINT32(exti_rtsr, STM32F4xxExtiState), | ||
262 | + VMSTATE_UINT32(exti_ftsr, STM32F4xxExtiState), | ||
263 | + VMSTATE_UINT32(exti_swier, STM32F4xxExtiState), | ||
264 | + VMSTATE_UINT32(exti_pr, STM32F4xxExtiState), | ||
265 | + VMSTATE_END_OF_LIST() | ||
266 | + } | 657 | + } |
267 | +}; | 658 | +}; |
268 | + | 659 | + |
269 | +static void stm32f4xx_exti_class_init(ObjectClass *klass, void *data) | 660 | +static void crl_class_init(ObjectClass *klass, void *data) |
270 | +{ | 661 | +{ |
662 | + ResettableClass *rc = RESETTABLE_CLASS(klass); | ||
271 | + DeviceClass *dc = DEVICE_CLASS(klass); | 663 | + DeviceClass *dc = DEVICE_CLASS(klass); |
272 | + | 664 | + |
273 | + dc->reset = stm32f4xx_exti_reset; | 665 | + dc->vmsd = &vmstate_crl; |
274 | + dc->vmsd = &vmstate_stm32f4xx_exti; | 666 | + |
275 | +} | 667 | + rc->phases.enter = crl_reset_enter; |
276 | + | 668 | + rc->phases.hold = crl_reset_hold; |
277 | +static const TypeInfo stm32f4xx_exti_info = { | 669 | +} |
278 | + .name = TYPE_STM32F4XX_EXTI, | 670 | + |
671 | +static const TypeInfo crl_info = { | ||
672 | + .name = TYPE_XLNX_VERSAL_CRL, | ||
279 | + .parent = TYPE_SYS_BUS_DEVICE, | 673 | + .parent = TYPE_SYS_BUS_DEVICE, |
280 | + .instance_size = sizeof(STM32F4xxExtiState), | 674 | + .instance_size = sizeof(XlnxVersalCRL), |
281 | + .instance_init = stm32f4xx_exti_init, | 675 | + .class_init = crl_class_init, |
282 | + .class_init = stm32f4xx_exti_class_init, | 676 | + .instance_init = crl_init, |
677 | + .instance_finalize = crl_finalize, | ||
283 | +}; | 678 | +}; |
284 | + | 679 | + |
285 | +static void stm32f4xx_exti_register_types(void) | 680 | +static void crl_register_types(void) |
286 | +{ | 681 | +{ |
287 | + type_register_static(&stm32f4xx_exti_info); | 682 | + type_register_static(&crl_info); |
288 | +} | 683 | +} |
289 | + | 684 | + |
290 | +type_init(stm32f4xx_exti_register_types) | 685 | +type_init(crl_register_types) |
291 | diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig | 686 | diff --git a/hw/misc/meson.build b/hw/misc/meson.build |
292 | index XXXXXXX..XXXXXXX 100644 | 687 | index XXXXXXX..XXXXXXX 100644 |
293 | --- a/hw/arm/Kconfig | 688 | --- a/hw/misc/meson.build |
294 | +++ b/hw/arm/Kconfig | 689 | +++ b/hw/misc/meson.build |
295 | @@ -XXX,XX +XXX,XX @@ config STM32F405_SOC | 690 | @@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c')) |
296 | bool | 691 | softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c')) |
297 | select ARM_V7M | 692 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-crf.c')) |
298 | select STM32F4XX_SYSCFG | 693 | specific_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp-apu-ctrl.c')) |
299 | + select STM32F4XX_EXTI | 694 | +specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-crl.c')) |
300 | 695 | softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( | |
301 | config XLNX_ZYNQMP_ARM | 696 | 'xlnx-versal-xramc.c', |
302 | bool | 697 | 'xlnx-versal-pmc-iou-slcr.c', |
303 | diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig | ||
304 | index XXXXXXX..XXXXXXX 100644 | ||
305 | --- a/hw/misc/Kconfig | ||
306 | +++ b/hw/misc/Kconfig | ||
307 | @@ -XXX,XX +XXX,XX @@ config STM32F2XX_SYSCFG | ||
308 | config STM32F4XX_SYSCFG | ||
309 | bool | ||
310 | |||
311 | +config STM32F4XX_EXTI | ||
312 | + bool | ||
313 | + | ||
314 | config MIPS_ITU | ||
315 | bool | ||
316 | |||
317 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
318 | index XXXXXXX..XXXXXXX 100644 | ||
319 | --- a/hw/misc/trace-events | ||
320 | +++ b/hw/misc/trace-events | ||
321 | @@ -XXX,XX +XXX,XX @@ stm32f4xx_pulse_exti(int irq) "Pulse EXTI: %d" | ||
322 | stm32f4xx_syscfg_read(uint64_t addr) "reg read: addr: 0x%" PRIx64 " " | ||
323 | stm32f4xx_syscfg_write(uint64_t addr, uint64_t data) "reg write: addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" | ||
324 | |||
325 | +# stm32f4xx_exti | ||
326 | +stm32f4xx_exti_set_irq(int irq, int leve) "Set EXTI: %d to %d" | ||
327 | +stm32f4xx_exti_read(uint64_t addr) "reg read: addr: 0x%" PRIx64 " " | ||
328 | +stm32f4xx_exti_write(uint64_t addr, uint64_t data) "reg write: addr: 0x%" PRIx64 " val: 0x%" PRIx64 "" | ||
329 | + | ||
330 | # tz-mpc.c | ||
331 | tz_mpc_reg_read(uint32_t offset, uint64_t data, unsigned size) "TZ MPC regs read: offset 0x%x data 0x%" PRIx64 " size %u" | ||
332 | tz_mpc_reg_write(uint32_t offset, uint64_t data, unsigned size) "TZ MPC regs write: offset 0x%x data 0x%" PRIx64 " size %u" | ||
333 | -- | 698 | -- |
334 | 2.20.1 | 699 | 2.25.1 |
335 | |||
336 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair@alistair23.me> | 1 | From: "Edgar E. Iglesias" <edgar.iglesias@amd.com> |
---|---|---|---|
2 | 2 | ||
3 | Signed-off-by: Alistair Francis <alistair@alistair23.me> | 3 | Connect the CRL (Clock Reset LPD) to the Versal SoC. |
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 4 | |
5 | Message-id: 1d145c4c13e5fa140caf131232a6f524c88fcd72.1576658572.git.alistair@alistair23.me | 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 | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
7 | --- | 10 | --- |
8 | hw/arm/Makefile.objs | 1 + | 11 | include/hw/arm/xlnx-versal.h | 4 +++ |
9 | include/hw/arm/stm32f405_soc.h | 73 ++++++++ | 12 | hw/arm/xlnx-versal.c | 54 ++++++++++++++++++++++++++++++++++-- |
10 | hw/arm/stm32f405_soc.c | 302 +++++++++++++++++++++++++++++++++ | 13 | 2 files changed, 56 insertions(+), 2 deletions(-) |
11 | MAINTAINERS | 8 + | ||
12 | 4 files changed, 384 insertions(+) | ||
13 | create mode 100644 include/hw/arm/stm32f405_soc.h | ||
14 | create mode 100644 hw/arm/stm32f405_soc.c | ||
15 | 14 | ||
16 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 15 | diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h |
17 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/arm/Makefile.objs | 17 | --- a/include/hw/arm/xlnx-versal.h |
19 | +++ b/hw/arm/Makefile.objs | 18 | +++ b/include/hw/arm/xlnx-versal.h |
20 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_STRONGARM) += strongarm.o | ||
21 | obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o | ||
22 | obj-$(CONFIG_RASPI) += bcm2835_peripherals.o bcm2836.o raspi.o | ||
23 | obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o | ||
24 | +obj-$(CONFIG_STM32F405_SOC) += stm32f405_soc.o | ||
25 | obj-$(CONFIG_XLNX_ZYNQMP_ARM) += xlnx-zynqmp.o xlnx-zcu102.o | ||
26 | obj-$(CONFIG_XLNX_VERSAL) += xlnx-versal.o xlnx-versal-virt.o | ||
27 | obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o | ||
28 | diff --git a/include/hw/arm/stm32f405_soc.h b/include/hw/arm/stm32f405_soc.h | ||
29 | new file mode 100644 | ||
30 | index XXXXXXX..XXXXXXX | ||
31 | --- /dev/null | ||
32 | +++ b/include/hw/arm/stm32f405_soc.h | ||
33 | @@ -XXX,XX +XXX,XX @@ | 19 | @@ -XXX,XX +XXX,XX @@ |
34 | +/* | 20 | #include "hw/nvram/xlnx-versal-efuse.h" |
35 | + * STM32F405 SoC | 21 | #include "hw/ssi/xlnx-versal-ospi.h" |
36 | + * | 22 | #include "hw/dma/xlnx_csu_dma.h" |
37 | + * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> | 23 | +#include "hw/misc/xlnx-versal-crl.h" |
38 | + * | 24 | #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" |
39 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | 25 | |
40 | + * of this software and associated documentation files (the "Software"), to deal | 26 | #define TYPE_XLNX_VERSAL "xlnx-versal" |
41 | + * in the Software without restriction, including without limitation the rights | 27 | @@ -XXX,XX +XXX,XX @@ struct Versal { |
42 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | 28 | qemu_or_irq irq_orgate; |
43 | + * copies of the Software, and to permit persons to whom the Software is | 29 | XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM]; |
44 | + * furnished to do so, subject to the following conditions: | 30 | } xram; |
45 | + * | ||
46 | + * The above copyright notice and this permission notice shall be included in | ||
47 | + * all copies or substantial portions of the Software. | ||
48 | + * | ||
49 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
50 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
51 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
52 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
53 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
54 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
55 | + * THE SOFTWARE. | ||
56 | + */ | ||
57 | + | 31 | + |
58 | +#ifndef HW_ARM_STM32F405_SOC_H | 32 | + XlnxVersalCRL crl; |
59 | +#define HW_ARM_STM32F405_SOC_H | 33 | } lpd; |
60 | + | 34 | |
61 | +#include "hw/misc/stm32f4xx_syscfg.h" | 35 | /* The Platform Management Controller subsystem. */ |
62 | +#include "hw/timer/stm32f2xx_timer.h" | 36 | @@ -XXX,XX +XXX,XX @@ struct Versal { |
63 | +#include "hw/char/stm32f2xx_usart.h" | 37 | #define VERSAL_TIMER_NS_EL1_IRQ 14 |
64 | +#include "hw/adc/stm32f2xx_adc.h" | 38 | #define VERSAL_TIMER_NS_EL2_IRQ 10 |
65 | +#include "hw/misc/stm32f4xx_exti.h" | 39 | |
66 | +#include "hw/or-irq.h" | 40 | +#define VERSAL_CRL_IRQ 10 |
67 | +#include "hw/ssi/stm32f2xx_spi.h" | 41 | #define VERSAL_UART0_IRQ_0 18 |
68 | +#include "hw/arm/armv7m.h" | 42 | #define VERSAL_UART1_IRQ_0 19 |
69 | + | 43 | #define VERSAL_USB0_IRQ_0 22 |
70 | +#define TYPE_STM32F405_SOC "stm32f405-soc" | 44 | diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c |
71 | +#define STM32F405_SOC(obj) \ | 45 | index XXXXXXX..XXXXXXX 100644 |
72 | + OBJECT_CHECK(STM32F405State, (obj), TYPE_STM32F405_SOC) | 46 | --- a/hw/arm/xlnx-versal.c |
73 | + | 47 | +++ b/hw/arm/xlnx-versal.c |
74 | +#define STM_NUM_USARTS 7 | 48 | @@ -XXX,XX +XXX,XX @@ static void versal_create_ospi(Versal *s, qemu_irq *pic) |
75 | +#define STM_NUM_TIMERS 4 | 49 | qdev_connect_gpio_out(orgate, 0, pic[VERSAL_OSPI_IRQ]); |
76 | +#define STM_NUM_ADCS 6 | 50 | } |
77 | +#define STM_NUM_SPIS 6 | 51 | |
78 | + | 52 | +static void versal_create_crl(Versal *s, qemu_irq *pic) |
79 | +#define FLASH_BASE_ADDRESS 0x08000000 | ||
80 | +#define FLASH_SIZE (1024 * 1024) | ||
81 | +#define SRAM_BASE_ADDRESS 0x20000000 | ||
82 | +#define SRAM_SIZE (192 * 1024) | ||
83 | + | ||
84 | +typedef struct STM32F405State { | ||
85 | + /*< private >*/ | ||
86 | + SysBusDevice parent_obj; | ||
87 | + /*< public >*/ | ||
88 | + | ||
89 | + char *cpu_type; | ||
90 | + | ||
91 | + ARMv7MState armv7m; | ||
92 | + | ||
93 | + STM32F4xxSyscfgState syscfg; | ||
94 | + STM32F4xxExtiState exti; | ||
95 | + STM32F2XXUsartState usart[STM_NUM_USARTS]; | ||
96 | + STM32F2XXTimerState timer[STM_NUM_TIMERS]; | ||
97 | + qemu_or_irq adc_irqs; | ||
98 | + STM32F2XXADCState adc[STM_NUM_ADCS]; | ||
99 | + STM32F2XXSPIState spi[STM_NUM_SPIS]; | ||
100 | + | ||
101 | + MemoryRegion sram; | ||
102 | + MemoryRegion flash; | ||
103 | + MemoryRegion flash_alias; | ||
104 | +} STM32F405State; | ||
105 | + | ||
106 | +#endif | ||
107 | diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c | ||
108 | new file mode 100644 | ||
109 | index XXXXXXX..XXXXXXX | ||
110 | --- /dev/null | ||
111 | +++ b/hw/arm/stm32f405_soc.c | ||
112 | @@ -XXX,XX +XXX,XX @@ | ||
113 | +/* | ||
114 | + * STM32F405 SoC | ||
115 | + * | ||
116 | + * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> | ||
117 | + * | ||
118 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
119 | + * of this software and associated documentation files (the "Software"), to deal | ||
120 | + * in the Software without restriction, including without limitation the rights | ||
121 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
122 | + * copies of the Software, and to permit persons to whom the Software is | ||
123 | + * furnished to do so, subject to the following conditions: | ||
124 | + * | ||
125 | + * The above copyright notice and this permission notice shall be included in | ||
126 | + * all copies or substantial portions of the Software. | ||
127 | + * | ||
128 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
129 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
130 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
131 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
132 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
133 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
134 | + * THE SOFTWARE. | ||
135 | + */ | ||
136 | + | ||
137 | +#include "qemu/osdep.h" | ||
138 | +#include "qapi/error.h" | ||
139 | +#include "qemu-common.h" | ||
140 | +#include "exec/address-spaces.h" | ||
141 | +#include "sysemu/sysemu.h" | ||
142 | +#include "hw/arm/stm32f405_soc.h" | ||
143 | +#include "hw/misc/unimp.h" | ||
144 | + | ||
145 | +#define SYSCFG_ADD 0x40013800 | ||
146 | +static const uint32_t usart_addr[] = { 0x40011000, 0x40004400, 0x40004800, | ||
147 | + 0x40004C00, 0x40005000, 0x40011400, | ||
148 | + 0x40007800, 0x40007C00 }; | ||
149 | +/* At the moment only Timer 2 to 5 are modelled */ | ||
150 | +static const uint32_t timer_addr[] = { 0x40000000, 0x40000400, | ||
151 | + 0x40000800, 0x40000C00 }; | ||
152 | +#define ADC_ADDR 0x40012000 | ||
153 | +static const uint32_t spi_addr[] = { 0x40013000, 0x40003800, 0x40003C00, | ||
154 | + 0x40013400, 0x40015000, 0x40015400 }; | ||
155 | +#define EXTI_ADDR 0x40013C00 | ||
156 | + | ||
157 | +#define SYSCFG_IRQ 71 | ||
158 | +static const int usart_irq[] = { 37, 38, 39, 52, 53, 71, 82, 83 }; | ||
159 | +static const int timer_irq[] = { 28, 29, 30, 50 }; | ||
160 | +#define ADC_IRQ 18 | ||
161 | +static const int spi_irq[] = { 35, 36, 51, 0, 0, 0 }; | ||
162 | +static const int exti_irq[] = { 6, 7, 8, 9, 10, 23, 23, 23, 23, 23, 40, | ||
163 | + 40, 40, 40, 40, 40} ; | ||
164 | + | ||
165 | + | ||
166 | +static void stm32f405_soc_initfn(Object *obj) | ||
167 | +{ | 53 | +{ |
168 | + STM32F405State *s = STM32F405_SOC(obj); | 54 | + SysBusDevice *sbd; |
169 | + int i; | 55 | + int i; |
170 | + | 56 | + |
171 | + sysbus_init_child_obj(obj, "armv7m", &s->armv7m, sizeof(s->armv7m), | 57 | + object_initialize_child(OBJECT(s), "crl", &s->lpd.crl, |
172 | + TYPE_ARMV7M); | 58 | + TYPE_XLNX_VERSAL_CRL); |
59 | + sbd = SYS_BUS_DEVICE(&s->lpd.crl); | ||
173 | + | 60 | + |
174 | + sysbus_init_child_obj(obj, "syscfg", &s->syscfg, sizeof(s->syscfg), | 61 | + for (i = 0; i < ARRAY_SIZE(s->lpd.rpu.cpu); i++) { |
175 | + TYPE_STM32F4XX_SYSCFG); | 62 | + g_autofree gchar *name = g_strdup_printf("cpu_r5[%d]", i); |
176 | + | 63 | + |
177 | + for (i = 0; i < STM_NUM_USARTS; i++) { | 64 | + object_property_set_link(OBJECT(&s->lpd.crl), |
178 | + sysbus_init_child_obj(obj, "usart[*]", &s->usart[i], | 65 | + name, OBJECT(&s->lpd.rpu.cpu[i]), |
179 | + sizeof(s->usart[i]), TYPE_STM32F2XX_USART); | 66 | + &error_abort); |
180 | + } | 67 | + } |
181 | + | 68 | + |
182 | + for (i = 0; i < STM_NUM_TIMERS; i++) { | 69 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.gem); i++) { |
183 | + sysbus_init_child_obj(obj, "timer[*]", &s->timer[i], | 70 | + g_autofree gchar *name = g_strdup_printf("gem[%d]", i); |
184 | + sizeof(s->timer[i]), TYPE_STM32F2XX_TIMER); | 71 | + |
72 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
73 | + name, OBJECT(&s->lpd.iou.gem[i]), | ||
74 | + &error_abort); | ||
185 | + } | 75 | + } |
186 | + | 76 | + |
187 | + for (i = 0; i < STM_NUM_ADCS; i++) { | 77 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.adma); i++) { |
188 | + sysbus_init_child_obj(obj, "adc[*]", &s->adc[i], sizeof(s->adc[i]), | 78 | + g_autofree gchar *name = g_strdup_printf("adma[%d]", i); |
189 | + TYPE_STM32F2XX_ADC); | 79 | + |
80 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
81 | + name, OBJECT(&s->lpd.iou.adma[i]), | ||
82 | + &error_abort); | ||
190 | + } | 83 | + } |
191 | + | 84 | + |
192 | + for (i = 0; i < STM_NUM_SPIS; i++) { | 85 | + for (i = 0; i < ARRAY_SIZE(s->lpd.iou.uart); i++) { |
193 | + sysbus_init_child_obj(obj, "spi[*]", &s->spi[i], sizeof(s->spi[i]), | 86 | + g_autofree gchar *name = g_strdup_printf("uart[%d]", i); |
194 | + TYPE_STM32F2XX_SPI); | 87 | + |
88 | + object_property_set_link(OBJECT(&s->lpd.crl), | ||
89 | + name, OBJECT(&s->lpd.iou.uart[i]), | ||
90 | + &error_abort); | ||
195 | + } | 91 | + } |
196 | + | 92 | + |
197 | + sysbus_init_child_obj(obj, "exti", &s->exti, sizeof(s->exti), | 93 | + object_property_set_link(OBJECT(&s->lpd.crl), |
198 | + TYPE_STM32F4XX_EXTI); | 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]); | ||
199 | +} | 101 | +} |
200 | + | 102 | + |
201 | +static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp) | 103 | /* This takes the board allocated linear DDR memory and creates aliases |
202 | +{ | 104 | * for each split DDR range/aperture on the Versal address map. |
203 | + STM32F405State *s = STM32F405_SOC(dev_soc); | 105 | */ |
204 | + MemoryRegion *system_memory = get_system_memory(); | 106 | @@ -XXX,XX +XXX,XX @@ static void versal_unimp(Versal *s) |
205 | + DeviceState *dev, *armv7m; | 107 | |
206 | + SysBusDevice *busdev; | 108 | versal_unimp_area(s, "psm", &s->mr_ps, |
207 | + Error *err = NULL; | 109 | MM_PSM_START, MM_PSM_END - MM_PSM_START); |
208 | + int i; | 110 | - versal_unimp_area(s, "crl", &s->mr_ps, |
209 | + | 111 | - MM_CRL, MM_CRL_SIZE); |
210 | + memory_region_init_ram(&s->flash, NULL, "STM32F405.flash", FLASH_SIZE, | 112 | versal_unimp_area(s, "crf", &s->mr_ps, |
211 | + &err); | 113 | MM_FPD_CRF, MM_FPD_CRF_SIZE); |
212 | + if (err != NULL) { | 114 | versal_unimp_area(s, "apu", &s->mr_ps, |
213 | + error_propagate(errp, err); | 115 | @@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp) |
214 | + return; | 116 | versal_create_efuse(s, pic); |
215 | + } | 117 | versal_create_pmc_iou_slcr(s, pic); |
216 | + memory_region_init_alias(&s->flash_alias, NULL, "STM32F405.flash.alias", | 118 | versal_create_ospi(s, pic); |
217 | + &s->flash, 0, FLASH_SIZE); | 119 | + versal_create_crl(s, pic); |
218 | + | 120 | versal_map_ddr(s); |
219 | + memory_region_set_readonly(&s->flash, true); | 121 | versal_unimp(s); |
220 | + memory_region_set_readonly(&s->flash_alias, true); | 122 | |
221 | + | ||
222 | + memory_region_add_subregion(system_memory, FLASH_BASE_ADDRESS, &s->flash); | ||
223 | + memory_region_add_subregion(system_memory, 0, &s->flash_alias); | ||
224 | + | ||
225 | + memory_region_init_ram(&s->sram, NULL, "STM32F405.sram", SRAM_SIZE, | ||
226 | + &err); | ||
227 | + if (err != NULL) { | ||
228 | + error_propagate(errp, err); | ||
229 | + return; | ||
230 | + } | ||
231 | + memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram); | ||
232 | + | ||
233 | + armv7m = DEVICE(&s->armv7m); | ||
234 | + qdev_prop_set_uint32(armv7m, "num-irq", 96); | ||
235 | + qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type); | ||
236 | + qdev_prop_set_bit(armv7m, "enable-bitband", true); | ||
237 | + object_property_set_link(OBJECT(&s->armv7m), OBJECT(system_memory), | ||
238 | + "memory", &error_abort); | ||
239 | + object_property_set_bool(OBJECT(&s->armv7m), true, "realized", &err); | ||
240 | + if (err != NULL) { | ||
241 | + error_propagate(errp, err); | ||
242 | + return; | ||
243 | + } | ||
244 | + | ||
245 | + /* System configuration controller */ | ||
246 | + dev = DEVICE(&s->syscfg); | ||
247 | + object_property_set_bool(OBJECT(&s->syscfg), true, "realized", &err); | ||
248 | + if (err != NULL) { | ||
249 | + error_propagate(errp, err); | ||
250 | + return; | ||
251 | + } | ||
252 | + busdev = SYS_BUS_DEVICE(dev); | ||
253 | + sysbus_mmio_map(busdev, 0, SYSCFG_ADD); | ||
254 | + sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, SYSCFG_IRQ)); | ||
255 | + | ||
256 | + /* Attach UART (uses USART registers) and USART controllers */ | ||
257 | + for (i = 0; i < STM_NUM_USARTS; i++) { | ||
258 | + dev = DEVICE(&(s->usart[i])); | ||
259 | + qdev_prop_set_chr(dev, "chardev", serial_hd(i)); | ||
260 | + object_property_set_bool(OBJECT(&s->usart[i]), true, "realized", &err); | ||
261 | + if (err != NULL) { | ||
262 | + error_propagate(errp, err); | ||
263 | + return; | ||
264 | + } | ||
265 | + busdev = SYS_BUS_DEVICE(dev); | ||
266 | + sysbus_mmio_map(busdev, 0, usart_addr[i]); | ||
267 | + sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, usart_irq[i])); | ||
268 | + } | ||
269 | + | ||
270 | + /* Timer 2 to 5 */ | ||
271 | + for (i = 0; i < STM_NUM_TIMERS; i++) { | ||
272 | + dev = DEVICE(&(s->timer[i])); | ||
273 | + qdev_prop_set_uint64(dev, "clock-frequency", 1000000000); | ||
274 | + object_property_set_bool(OBJECT(&s->timer[i]), true, "realized", &err); | ||
275 | + if (err != NULL) { | ||
276 | + error_propagate(errp, err); | ||
277 | + return; | ||
278 | + } | ||
279 | + busdev = SYS_BUS_DEVICE(dev); | ||
280 | + sysbus_mmio_map(busdev, 0, timer_addr[i]); | ||
281 | + sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, timer_irq[i])); | ||
282 | + } | ||
283 | + | ||
284 | + /* ADC device, the IRQs are ORed together */ | ||
285 | + object_initialize_child(OBJECT(s), "adc-orirq", &s->adc_irqs, | ||
286 | + sizeof(s->adc_irqs), TYPE_OR_IRQ, | ||
287 | + &err, NULL); | ||
288 | + if (err != NULL) { | ||
289 | + error_propagate(errp, err); | ||
290 | + return; | ||
291 | + } | ||
292 | + object_property_set_int(OBJECT(&s->adc_irqs), STM_NUM_ADCS, | ||
293 | + "num-lines", &err); | ||
294 | + object_property_set_bool(OBJECT(&s->adc_irqs), true, "realized", &err); | ||
295 | + if (err != NULL) { | ||
296 | + error_propagate(errp, err); | ||
297 | + return; | ||
298 | + } | ||
299 | + qdev_connect_gpio_out(DEVICE(&s->adc_irqs), 0, | ||
300 | + qdev_get_gpio_in(armv7m, ADC_IRQ)); | ||
301 | + | ||
302 | + dev = DEVICE(&(s->adc[i])); | ||
303 | + object_property_set_bool(OBJECT(&s->adc[i]), true, "realized", &err); | ||
304 | + if (err != NULL) { | ||
305 | + error_propagate(errp, err); | ||
306 | + return; | ||
307 | + } | ||
308 | + busdev = SYS_BUS_DEVICE(dev); | ||
309 | + sysbus_mmio_map(busdev, 0, ADC_ADDR); | ||
310 | + sysbus_connect_irq(busdev, 0, | ||
311 | + qdev_get_gpio_in(DEVICE(&s->adc_irqs), i)); | ||
312 | + | ||
313 | + /* SPI devices */ | ||
314 | + for (i = 0; i < STM_NUM_SPIS; i++) { | ||
315 | + dev = DEVICE(&(s->spi[i])); | ||
316 | + object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err); | ||
317 | + if (err != NULL) { | ||
318 | + error_propagate(errp, err); | ||
319 | + return; | ||
320 | + } | ||
321 | + busdev = SYS_BUS_DEVICE(dev); | ||
322 | + sysbus_mmio_map(busdev, 0, spi_addr[i]); | ||
323 | + sysbus_connect_irq(busdev, 0, qdev_get_gpio_in(armv7m, spi_irq[i])); | ||
324 | + } | ||
325 | + | ||
326 | + /* EXTI device */ | ||
327 | + dev = DEVICE(&s->exti); | ||
328 | + object_property_set_bool(OBJECT(&s->exti), true, "realized", &err); | ||
329 | + if (err != NULL) { | ||
330 | + error_propagate(errp, err); | ||
331 | + return; | ||
332 | + } | ||
333 | + busdev = SYS_BUS_DEVICE(dev); | ||
334 | + sysbus_mmio_map(busdev, 0, EXTI_ADDR); | ||
335 | + for (i = 0; i < 16; i++) { | ||
336 | + sysbus_connect_irq(busdev, i, qdev_get_gpio_in(armv7m, exti_irq[i])); | ||
337 | + } | ||
338 | + for (i = 0; i < 16; i++) { | ||
339 | + qdev_connect_gpio_out(DEVICE(&s->syscfg), i, qdev_get_gpio_in(dev, i)); | ||
340 | + } | ||
341 | + | ||
342 | + create_unimplemented_device("timer[7]", 0x40001400, 0x400); | ||
343 | + create_unimplemented_device("timer[12]", 0x40001800, 0x400); | ||
344 | + create_unimplemented_device("timer[6]", 0x40001000, 0x400); | ||
345 | + create_unimplemented_device("timer[13]", 0x40001C00, 0x400); | ||
346 | + create_unimplemented_device("timer[14]", 0x40002000, 0x400); | ||
347 | + create_unimplemented_device("RTC and BKP", 0x40002800, 0x400); | ||
348 | + create_unimplemented_device("WWDG", 0x40002C00, 0x400); | ||
349 | + create_unimplemented_device("IWDG", 0x40003000, 0x400); | ||
350 | + create_unimplemented_device("I2S2ext", 0x40003000, 0x400); | ||
351 | + create_unimplemented_device("I2S3ext", 0x40004000, 0x400); | ||
352 | + create_unimplemented_device("I2C1", 0x40005400, 0x400); | ||
353 | + create_unimplemented_device("I2C2", 0x40005800, 0x400); | ||
354 | + create_unimplemented_device("I2C3", 0x40005C00, 0x400); | ||
355 | + create_unimplemented_device("CAN1", 0x40006400, 0x400); | ||
356 | + create_unimplemented_device("CAN2", 0x40006800, 0x400); | ||
357 | + create_unimplemented_device("PWR", 0x40007000, 0x400); | ||
358 | + create_unimplemented_device("DAC", 0x40007400, 0x400); | ||
359 | + create_unimplemented_device("timer[1]", 0x40010000, 0x400); | ||
360 | + create_unimplemented_device("timer[8]", 0x40010400, 0x400); | ||
361 | + create_unimplemented_device("SDIO", 0x40012C00, 0x400); | ||
362 | + create_unimplemented_device("timer[9]", 0x40014000, 0x400); | ||
363 | + create_unimplemented_device("timer[10]", 0x40014400, 0x400); | ||
364 | + create_unimplemented_device("timer[11]", 0x40014800, 0x400); | ||
365 | + create_unimplemented_device("GPIOA", 0x40020000, 0x400); | ||
366 | + create_unimplemented_device("GPIOB", 0x40020400, 0x400); | ||
367 | + create_unimplemented_device("GPIOC", 0x40020800, 0x400); | ||
368 | + create_unimplemented_device("GPIOD", 0x40020C00, 0x400); | ||
369 | + create_unimplemented_device("GPIOE", 0x40021000, 0x400); | ||
370 | + create_unimplemented_device("GPIOF", 0x40021400, 0x400); | ||
371 | + create_unimplemented_device("GPIOG", 0x40021800, 0x400); | ||
372 | + create_unimplemented_device("GPIOH", 0x40021C00, 0x400); | ||
373 | + create_unimplemented_device("GPIOI", 0x40022000, 0x400); | ||
374 | + create_unimplemented_device("CRC", 0x40023000, 0x400); | ||
375 | + create_unimplemented_device("RCC", 0x40023800, 0x400); | ||
376 | + create_unimplemented_device("Flash Int", 0x40023C00, 0x400); | ||
377 | + create_unimplemented_device("BKPSRAM", 0x40024000, 0x400); | ||
378 | + create_unimplemented_device("DMA1", 0x40026000, 0x400); | ||
379 | + create_unimplemented_device("DMA2", 0x40026400, 0x400); | ||
380 | + create_unimplemented_device("Ethernet", 0x40028000, 0x1400); | ||
381 | + create_unimplemented_device("USB OTG HS", 0x40040000, 0x30000); | ||
382 | + create_unimplemented_device("USB OTG FS", 0x50000000, 0x31000); | ||
383 | + create_unimplemented_device("DCMI", 0x50050000, 0x400); | ||
384 | + create_unimplemented_device("RNG", 0x50060800, 0x400); | ||
385 | +} | ||
386 | + | ||
387 | +static Property stm32f405_soc_properties[] = { | ||
388 | + DEFINE_PROP_STRING("cpu-type", STM32F405State, cpu_type), | ||
389 | + DEFINE_PROP_END_OF_LIST(), | ||
390 | +}; | ||
391 | + | ||
392 | +static void stm32f405_soc_class_init(ObjectClass *klass, void *data) | ||
393 | +{ | ||
394 | + DeviceClass *dc = DEVICE_CLASS(klass); | ||
395 | + | ||
396 | + dc->realize = stm32f405_soc_realize; | ||
397 | + dc->props = stm32f405_soc_properties; | ||
398 | + /* No vmstate or reset required: device has no internal state */ | ||
399 | +} | ||
400 | + | ||
401 | +static const TypeInfo stm32f405_soc_info = { | ||
402 | + .name = TYPE_STM32F405_SOC, | ||
403 | + .parent = TYPE_SYS_BUS_DEVICE, | ||
404 | + .instance_size = sizeof(STM32F405State), | ||
405 | + .instance_init = stm32f405_soc_initfn, | ||
406 | + .class_init = stm32f405_soc_class_init, | ||
407 | +}; | ||
408 | + | ||
409 | +static void stm32f405_soc_types(void) | ||
410 | +{ | ||
411 | + type_register_static(&stm32f405_soc_info); | ||
412 | +} | ||
413 | + | ||
414 | +type_init(stm32f405_soc_types) | ||
415 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
416 | index XXXXXXX..XXXXXXX 100644 | ||
417 | --- a/MAINTAINERS | ||
418 | +++ b/MAINTAINERS | ||
419 | @@ -XXX,XX +XXX,XX @@ F: hw/adc/* | ||
420 | F: hw/ssi/stm32f2xx_spi.c | ||
421 | F: include/hw/*/stm32*.h | ||
422 | |||
423 | +STM32F405 | ||
424 | +M: Alistair Francis <alistair@alistair23.me> | ||
425 | +M: Peter Maydell <peter.maydell@linaro.org> | ||
426 | +S: Maintained | ||
427 | +F: hw/arm/stm32f405_soc.c | ||
428 | +F: hw/misc/stm32f4xx_syscfg.c | ||
429 | +F: hw/misc/stm32f4xx_exti.c | ||
430 | + | ||
431 | Netduino 2 | ||
432 | M: Alistair Francis <alistair@alistair23.me> | ||
433 | M: Peter Maydell <peter.maydell@linaro.org> | ||
434 | -- | 123 | -- |
435 | 2.20.1 | 124 | 2.25.1 |
436 | |||
437 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | The Exynos4210 SoC device currently uses a custom device | ||
2 | "exynos4210.irq_gate" to model the OR gate that feeds each CPU's IRQ | ||
3 | line. We have a standard TYPE_OR_IRQ device for this now, so use | ||
4 | that instead. | ||
1 | 5 | ||
6 | (This is a migration compatibility break, but that is OK for this | ||
7 | machine type.) | ||
8 | |||
9 | 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 | --- | ||
13 | include/hw/arm/exynos4210.h | 1 + | ||
14 | hw/arm/exynos4210.c | 31 ++++++++++++++++--------------- | ||
15 | 2 files changed, 17 insertions(+), 15 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 @@ struct Exynos4210State { | ||
22 | MemoryRegion bootreg_mem; | ||
23 | I2CBus *i2c_if[EXYNOS4210_I2C_NUMBER]; | ||
24 | qemu_or_irq pl330_irq_orgate[EXYNOS4210_NUM_DMA]; | ||
25 | + qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; | ||
26 | }; | ||
27 | |||
28 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
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 | { | ||
35 | Exynos4210State *s = EXYNOS4210_SOC(socdev); | ||
36 | MemoryRegion *system_mem = get_system_memory(); | ||
37 | - qemu_irq gate_irq[EXYNOS4210_NCPUS][EXYNOS4210_IRQ_GATE_NINPUTS]; | ||
38 | SysBusDevice *busdev; | ||
39 | DeviceState *dev, *uart[4], *pl330[3]; | ||
40 | int i, n; | ||
41 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
42 | |||
43 | /* IRQ Gate */ | ||
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 | + } | ||
96 | } | ||
97 | |||
98 | static void exynos4210_class_init(ObjectClass *klass, void *data) | ||
99 | -- | ||
100 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Now we have removed the only use of TYPE_EXYNOS4210_IRQ_GATE we can | ||
2 | delete the device entirely. | ||
1 | 3 | ||
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 |
New 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. | ||
1 | 6 | ||
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 |
New 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. | ||
1 | 8 | ||
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 |
1 | From: Jeff Kubascik <jeff.kubascik@dornerworks.com> | 1 | The exynos4210 code currently has two very similar arrays of IRQs: |
---|---|---|---|
2 | 2 | ||
3 | The wfi instruction can be configured to be trapped by a higher exception | 3 | * board_irqs is a field of the Exynos4210Irq struct which is filled |
4 | level, such as the EL2 hypervisor. When the instruction is trapped, the | 4 | in by exynos4210_init_board_irqs() with the appropriate qemu_irqs |
5 | program counter should contain the address of the wfi instruction that | 5 | for each IRQ the board/SoC can assert |
6 | caused the exception. The program counter is adjusted for this in the wfi op | 6 | * irq_table is a set of qemu_irqs pointed to from the |
7 | helper function. | 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 | ||
8 | 10 | ||
9 | However, this correction is done to env->pc, which only applies to AArch64 | 11 | The extra indirection through irq_table is unnecessary, so coalesce |
10 | mode. For AArch32, the program counter is stored in env->regs[15]. This | 12 | these into a single irq_table[] array as a direct field in |
11 | adds an if-else statement to modify the correct program counter location | 13 | Exynos4210State which exynos4210_init_board_irqs() fills in. |
12 | based on the the current CPU mode. | ||
13 | 14 | ||
14 | Signed-off-by: Jeff Kubascik <jeff.kubascik@dornerworks.com> | 15 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
15 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | 16 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
16 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 17 | Message-id: 20220404154658.565020-6-peter.maydell@linaro.org |
17 | --- | 18 | --- |
18 | target/arm/op_helper.c | 7 ++++++- | 19 | include/hw/arm/exynos4210.h | 8 ++------ |
19 | 1 file changed, 6 insertions(+), 1 deletion(-) | 20 | hw/arm/exynos4210.c | 6 +----- |
21 | hw/intc/exynos4210_gic.c | 32 ++++++++------------------------ | ||
22 | 3 files changed, 11 insertions(+), 35 deletions(-) | ||
20 | 23 | ||
21 | diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c | 24 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
22 | index XXXXXXX..XXXXXXX 100644 | 25 | index XXXXXXX..XXXXXXX 100644 |
23 | --- a/target/arm/op_helper.c | 26 | --- a/include/hw/arm/exynos4210.h |
24 | +++ b/target/arm/op_helper.c | 27 | +++ b/include/hw/arm/exynos4210.h |
25 | @@ -XXX,XX +XXX,XX @@ void HELPER(wfi)(CPUARMState *env, uint32_t insn_len) | 28 | @@ -XXX,XX +XXX,XX @@ typedef struct Exynos4210Irq { |
29 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
30 | qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; | ||
31 | qemu_irq ext_gic_irq[EXYNOS4210_EXT_GIC_NIRQ]; | ||
32 | - qemu_irq board_irqs[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
33 | } Exynos4210Irq; | ||
34 | |||
35 | struct Exynos4210State { | ||
36 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { | ||
37 | /*< public >*/ | ||
38 | ARMCPU *cpu[EXYNOS4210_NCPUS]; | ||
39 | Exynos4210Irq irqs; | ||
40 | - qemu_irq *irq_table; | ||
41 | + qemu_irq irq_table[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
42 | |||
43 | MemoryRegion chipid_mem; | ||
44 | MemoryRegion iram_mem; | ||
45 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) | ||
46 | void exynos4210_write_secondary(ARMCPU *cpu, | ||
47 | const struct arm_boot_info *info); | ||
48 | |||
49 | -/* Initialize exynos4210 IRQ subsystem stub */ | ||
50 | -qemu_irq *exynos4210_init_irq(Exynos4210Irq *env); | ||
51 | - | ||
52 | /* Initialize board IRQs. | ||
53 | * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ | ||
54 | -void exynos4210_init_board_irqs(Exynos4210Irq *s); | ||
55 | +void exynos4210_init_board_irqs(Exynos4210State *s); | ||
56 | |||
57 | /* Get IRQ number from exynos4210 IRQ subsystem stub. | ||
58 | * To identify IRQ source use internal combiner group and bit number | ||
59 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
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); | ||
26 | } | 65 | } |
27 | 66 | ||
28 | if (target_el) { | 67 | - /*** IRQs ***/ |
29 | - env->pc -= insn_len; | 68 | - |
30 | + if (env->aarch64) { | 69 | - s->irq_table = exynos4210_init_irq(&s->irqs); |
31 | + env->pc -= insn_len; | 70 | - |
32 | + } else { | 71 | /* IRQ Gate */ |
33 | + env->regs[15] -= insn_len; | 72 | for (i = 0; i < EXYNOS4210_NCPUS; i++) { |
34 | + } | 73 | DeviceState *orgate = DEVICE(&s->cpu_irq_orgate[i]); |
35 | + | 74 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
36 | raise_exception(env, EXCP_UDEF, syn_wfx(1, 0xe, 0, insn_len == 2), | 75 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); |
37 | target_el); | 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 | } | ||
38 | } | 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 | } | ||
146 | } | ||
39 | -- | 147 | -- |
40 | 2.20.1 | 148 | 2.25.1 |
41 | |||
42 | diff view generated by jsdifflib |
New 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. | ||
1 | 5 | ||
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 |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | The function exynos4210_init_board_irqs() currently lives in |
---|---|---|---|
2 | exynos4210_gic.c, but it isn't really part of the exynos4210.gic | ||
3 | device -- it is a function that implements (some of) the wiring up of | ||
4 | interrupts between the SoC's GIC and combiner components. This means | ||
5 | it fits better in exynos4210.c, which is the SoC-level code. Move it | ||
6 | there. Similarly, exynos4210_git_irq() is used almost only in the | ||
7 | SoC-level code, so move it too. | ||
2 | 8 | ||
3 | By calling qdev_pass_gpios() we don't need to hold a copy of the | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | IRQs from the INTC into the SoC state. | 10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | Instead of filling an array of qemu_irq and passing it around, we | 11 | Message-id: 20220404154658.565020-8-peter.maydell@linaro.org |
6 | can now directly call qdev_get_gpio_in() on the SoC. | 12 | --- |
13 | include/hw/arm/exynos4210.h | 4 - | ||
14 | hw/arm/exynos4210.c | 202 +++++++++++++++++++++++++++++++++++ | ||
15 | hw/intc/exynos4210_gic.c | 204 ------------------------------------ | ||
16 | 3 files changed, 202 insertions(+), 208 deletions(-) | ||
7 | 17 | ||
8 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
9 | Message-id: 20191230110953.25496-5-f4bug@amsat.org | ||
10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | --- | ||
13 | include/hw/arm/allwinner-a10.h | 1 - | ||
14 | hw/arm/allwinner-a10.c | 24 +++++++++++------------- | ||
15 | 2 files changed, 11 insertions(+), 14 deletions(-) | ||
16 | |||
17 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h | ||
18 | index XXXXXXX..XXXXXXX 100644 | 19 | index XXXXXXX..XXXXXXX 100644 |
19 | --- a/include/hw/arm/allwinner-a10.h | 20 | --- a/include/hw/arm/exynos4210.h |
20 | +++ b/include/hw/arm/allwinner-a10.h | 21 | +++ b/include/hw/arm/exynos4210.h |
21 | @@ -XXX,XX +XXX,XX @@ typedef struct AwA10State { | 22 | @@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210State, EXYNOS4210_SOC) |
22 | /*< public >*/ | 23 | void exynos4210_write_secondary(ARMCPU *cpu, |
23 | 24 | const struct arm_boot_info *info); | |
24 | ARMCPU cpu; | 25 | |
25 | - qemu_irq irq[AW_A10_PIC_INT_NR]; | 26 | -/* Initialize board IRQs. |
26 | AwA10PITState timer; | 27 | - * These IRQs contain splitted Int/External Combiner and External Gic IRQs */ |
27 | AwA10PICState intc; | 28 | -void exynos4210_init_board_irqs(Exynos4210State *s); |
28 | AwEmacState emac; | 29 | - |
29 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c | 30 | /* Get IRQ number from exynos4210 IRQ subsystem stub. |
31 | * To identify IRQ source use internal combiner group and bit number | ||
32 | * grp - group number | ||
33 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | 34 | index XXXXXXX..XXXXXXX 100644 |
31 | --- a/hw/arm/allwinner-a10.c | 35 | --- a/hw/arm/exynos4210.c |
32 | +++ b/hw/arm/allwinner-a10.c | 36 | +++ b/hw/arm/exynos4210.c |
33 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | 37 | @@ -XXX,XX +XXX,XX @@ |
34 | { | 38 | #define EXYNOS4210_PL330_BASE1_ADDR 0x12690000 |
35 | AwA10State *s = AW_A10(dev); | 39 | #define EXYNOS4210_PL330_BASE2_ADDR 0x12850000 |
36 | SysBusDevice *sysbusdev; | 40 | |
37 | - uint8_t i; | 41 | +enum ExtGicId { |
38 | qemu_irq fiq, irq; | 42 | + EXT_GIC_ID_MDMA_LCD0 = 66, |
39 | Error *err = NULL; | 43 | + EXT_GIC_ID_PDMA0, |
40 | 44 | + EXT_GIC_ID_PDMA1, | |
41 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | 45 | + EXT_GIC_ID_TIMER0, |
42 | sysbus_mmio_map(sysbusdev, 0, AW_A10_PIC_REG_BASE); | 46 | + EXT_GIC_ID_TIMER1, |
43 | sysbus_connect_irq(sysbusdev, 0, irq); | 47 | + EXT_GIC_ID_TIMER2, |
44 | sysbus_connect_irq(sysbusdev, 1, fiq); | 48 | + EXT_GIC_ID_TIMER3, |
45 | - for (i = 0; i < AW_A10_PIC_INT_NR; i++) { | 49 | + EXT_GIC_ID_TIMER4, |
46 | - s->irq[i] = qdev_get_gpio_in(DEVICE(&s->intc), i); | 50 | + EXT_GIC_ID_MCT_L0, |
51 | + EXT_GIC_ID_WDT, | ||
52 | + EXT_GIC_ID_RTC_ALARM, | ||
53 | + EXT_GIC_ID_RTC_TIC, | ||
54 | + EXT_GIC_ID_GPIO_XB, | ||
55 | + EXT_GIC_ID_GPIO_XA, | ||
56 | + EXT_GIC_ID_MCT_L1, | ||
57 | + EXT_GIC_ID_IEM_APC, | ||
58 | + EXT_GIC_ID_IEM_IEC, | ||
59 | + EXT_GIC_ID_NFC, | ||
60 | + EXT_GIC_ID_UART0, | ||
61 | + EXT_GIC_ID_UART1, | ||
62 | + EXT_GIC_ID_UART2, | ||
63 | + EXT_GIC_ID_UART3, | ||
64 | + EXT_GIC_ID_UART4, | ||
65 | + EXT_GIC_ID_MCT_G0, | ||
66 | + EXT_GIC_ID_I2C0, | ||
67 | + EXT_GIC_ID_I2C1, | ||
68 | + EXT_GIC_ID_I2C2, | ||
69 | + EXT_GIC_ID_I2C3, | ||
70 | + EXT_GIC_ID_I2C4, | ||
71 | + EXT_GIC_ID_I2C5, | ||
72 | + EXT_GIC_ID_I2C6, | ||
73 | + EXT_GIC_ID_I2C7, | ||
74 | + EXT_GIC_ID_SPI0, | ||
75 | + EXT_GIC_ID_SPI1, | ||
76 | + EXT_GIC_ID_SPI2, | ||
77 | + EXT_GIC_ID_MCT_G1, | ||
78 | + EXT_GIC_ID_USB_HOST, | ||
79 | + EXT_GIC_ID_USB_DEVICE, | ||
80 | + EXT_GIC_ID_MODEMIF, | ||
81 | + EXT_GIC_ID_HSMMC0, | ||
82 | + EXT_GIC_ID_HSMMC1, | ||
83 | + EXT_GIC_ID_HSMMC2, | ||
84 | + EXT_GIC_ID_HSMMC3, | ||
85 | + EXT_GIC_ID_SDMMC, | ||
86 | + EXT_GIC_ID_MIPI_CSI_4LANE, | ||
87 | + EXT_GIC_ID_MIPI_DSI_4LANE, | ||
88 | + EXT_GIC_ID_MIPI_CSI_2LANE, | ||
89 | + EXT_GIC_ID_MIPI_DSI_2LANE, | ||
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 | +{ | ||
195 | + uint32_t grp, bit, irq_id, n; | ||
196 | + Exynos4210Irq *is = &s->irqs; | ||
197 | + | ||
198 | + for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
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 | + } | ||
217 | + } | ||
218 | + for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { | ||
219 | + /* these IDs are passed to Internal Combiner and External GIC */ | ||
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 | + | ||
225 | + if (irq_id) { | ||
226 | + s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], | ||
227 | + is->ext_gic_irq[irq_id - 32]); | ||
228 | + } | ||
229 | + } | ||
230 | +} | ||
231 | + | ||
232 | +/* | ||
233 | + * Get IRQ number from exynos4210 IRQ subsystem stub. | ||
234 | + * To identify IRQ source use internal combiner group and bit number | ||
235 | + * grp - group number | ||
236 | + * bit - bit number inside group | ||
237 | + */ | ||
238 | +uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | ||
239 | +{ | ||
240 | + return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); | ||
241 | +} | ||
242 | + | ||
243 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
244 | 0x09, 0x00, 0x00, 0x00 }; | ||
245 | |||
246 | diff --git a/hw/intc/exynos4210_gic.c b/hw/intc/exynos4210_gic.c | ||
247 | index XXXXXXX..XXXXXXX 100644 | ||
248 | --- a/hw/intc/exynos4210_gic.c | ||
249 | +++ b/hw/intc/exynos4210_gic.c | ||
250 | @@ -XXX,XX +XXX,XX @@ | ||
251 | #include "hw/arm/exynos4210.h" | ||
252 | #include "qom/object.h" | ||
253 | |||
254 | -enum ExtGicId { | ||
255 | - EXT_GIC_ID_MDMA_LCD0 = 66, | ||
256 | - EXT_GIC_ID_PDMA0, | ||
257 | - EXT_GIC_ID_PDMA1, | ||
258 | - EXT_GIC_ID_TIMER0, | ||
259 | - EXT_GIC_ID_TIMER1, | ||
260 | - EXT_GIC_ID_TIMER2, | ||
261 | - EXT_GIC_ID_TIMER3, | ||
262 | - EXT_GIC_ID_TIMER4, | ||
263 | - EXT_GIC_ID_MCT_L0, | ||
264 | - EXT_GIC_ID_WDT, | ||
265 | - EXT_GIC_ID_RTC_ALARM, | ||
266 | - EXT_GIC_ID_RTC_TIC, | ||
267 | - EXT_GIC_ID_GPIO_XB, | ||
268 | - EXT_GIC_ID_GPIO_XA, | ||
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 | - } | ||
47 | - } | 437 | - } |
48 | + qdev_pass_gpios(DEVICE(&s->intc), dev, NULL); | 438 | - for (; n < EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; n++) { |
49 | 439 | - /* these IDs are passed to Internal Combiner and External GIC */ | |
50 | object_property_set_bool(OBJECT(&s->timer), true, "realized", &err); | 440 | - grp = EXYNOS4210_COMBINER_GET_GRP_NUM(n); |
51 | if (err != NULL) { | 441 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); |
52 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | 442 | - irq_id = combiner_grp_to_gic_id[grp - |
53 | } | 443 | - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; |
54 | sysbusdev = SYS_BUS_DEVICE(&s->timer); | 444 | - |
55 | sysbus_mmio_map(sysbusdev, 0, AW_A10_PIT_REG_BASE); | 445 | - if (irq_id) { |
56 | - sysbus_connect_irq(sysbusdev, 0, s->irq[22]); | 446 | - s->irq_table[n] = qemu_irq_split(is->int_combiner_irq[n], |
57 | - sysbus_connect_irq(sysbusdev, 1, s->irq[23]); | 447 | - is->ext_gic_irq[irq_id - 32]); |
58 | - sysbus_connect_irq(sysbusdev, 2, s->irq[24]); | 448 | - } |
59 | - sysbus_connect_irq(sysbusdev, 3, s->irq[25]); | 449 | - } |
60 | - sysbus_connect_irq(sysbusdev, 4, s->irq[67]); | 450 | -} |
61 | - sysbus_connect_irq(sysbusdev, 5, s->irq[68]); | 451 | - |
62 | + sysbus_connect_irq(sysbusdev, 0, qdev_get_gpio_in(dev, 22)); | 452 | -/* |
63 | + sysbus_connect_irq(sysbusdev, 1, qdev_get_gpio_in(dev, 23)); | 453 | - * Get IRQ number from exynos4210 IRQ subsystem stub. |
64 | + sysbus_connect_irq(sysbusdev, 2, qdev_get_gpio_in(dev, 24)); | 454 | - * To identify IRQ source use internal combiner group and bit number |
65 | + sysbus_connect_irq(sysbusdev, 3, qdev_get_gpio_in(dev, 25)); | 455 | - * grp - group number |
66 | + sysbus_connect_irq(sysbusdev, 4, qdev_get_gpio_in(dev, 67)); | 456 | - * bit - bit number inside group |
67 | + sysbus_connect_irq(sysbusdev, 5, qdev_get_gpio_in(dev, 68)); | 457 | - */ |
68 | 458 | -uint32_t exynos4210_get_irq(uint32_t grp, uint32_t bit) | |
69 | memory_region_init_ram(&s->sram_a, OBJECT(dev), "sram A", 48 * KiB, | 459 | -{ |
70 | &error_fatal); | 460 | - return EXYNOS4210_COMBINER_GET_IRQ_NUM(grp, bit); |
71 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | 461 | -} |
72 | } | 462 | - |
73 | sysbusdev = SYS_BUS_DEVICE(&s->emac); | 463 | -/********* GIC part *********/ |
74 | sysbus_mmio_map(sysbusdev, 0, AW_A10_EMAC_BASE); | 464 | - |
75 | - sysbus_connect_irq(sysbusdev, 0, s->irq[55]); | 465 | #define TYPE_EXYNOS4210_GIC "exynos4210.gic" |
76 | + sysbus_connect_irq(sysbusdev, 0, qdev_get_gpio_in(dev, 55)); | 466 | OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) |
77 | |||
78 | object_property_set_bool(OBJECT(&s->sata), true, "realized", &err); | ||
79 | if (err) { | ||
80 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | ||
81 | return; | ||
82 | } | ||
83 | sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, AW_A10_SATA_BASE); | ||
84 | - sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, s->irq[56]); | ||
85 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, qdev_get_gpio_in(dev, 56)); | ||
86 | |||
87 | /* FIXME use a qdev chardev prop instead of serial_hd() */ | ||
88 | - serial_mm_init(get_system_memory(), AW_A10_UART0_REG_BASE, 2, s->irq[1], | ||
89 | + serial_mm_init(get_system_memory(), AW_A10_UART0_REG_BASE, 2, | ||
90 | + qdev_get_gpio_in(dev, 1), | ||
91 | 115200, serial_hd(0), DEVICE_NATIVE_ENDIAN); | ||
92 | } | ||
93 | 467 | ||
94 | -- | 468 | -- |
95 | 2.20.1 | 469 | 2.25.1 |
96 | |||
97 | diff view generated by jsdifflib |
1 | From: Alistair Francis <alistair@alistair23.me> | 1 | Switch the creation of the external GIC to the new-style "embedded in |
---|---|---|---|
2 | state struct" approach, so we can easily refer to the object | ||
3 | elsewhere during realize. | ||
2 | 4 | ||
3 | Signed-off-by: Alistair Francis <alistair@alistair23.me> | ||
4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Message-id: dad8d8d47f7625913e35e27a1c00f603a6b08f9a.1576658572.git.alistair@alistair23.me | ||
6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
7 | Message-id: 20220404154658.565020-9-peter.maydell@linaro.org | ||
7 | --- | 8 | --- |
8 | hw/arm/Makefile.objs | 1 + | 9 | include/hw/arm/exynos4210.h | 2 ++ |
9 | hw/arm/netduinoplus2.c | 52 ++++++++++++++++++++++++++++++++++++++++++ | 10 | include/hw/intc/exynos4210_gic.h | 43 ++++++++++++++++++++++++++++++++ |
10 | MAINTAINERS | 6 +++++ | 11 | hw/arm/exynos4210.c | 10 ++++---- |
11 | 3 files changed, 59 insertions(+) | 12 | hw/intc/exynos4210_gic.c | 17 ++----------- |
12 | create mode 100644 hw/arm/netduinoplus2.c | 13 | MAINTAINERS | 2 +- |
14 | 5 files changed, 53 insertions(+), 21 deletions(-) | ||
15 | create mode 100644 include/hw/intc/exynos4210_gic.h | ||
13 | 16 | ||
14 | diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs | 17 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
15 | index XXXXXXX..XXXXXXX 100644 | 18 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/Makefile.objs | 19 | --- a/include/hw/arm/exynos4210.h |
17 | +++ b/hw/arm/Makefile.objs | 20 | +++ b/include/hw/arm/exynos4210.h |
18 | @@ -XXX,XX +XXX,XX @@ obj-$(CONFIG_MAINSTONE) += mainstone.o | 21 | @@ -XXX,XX +XXX,XX @@ |
19 | obj-$(CONFIG_MICROBIT) += microbit.o | 22 | #include "hw/or-irq.h" |
20 | obj-$(CONFIG_MUSICPAL) += musicpal.o | 23 | #include "hw/sysbus.h" |
21 | obj-$(CONFIG_NETDUINO2) += netduino2.o | 24 | #include "hw/cpu/a9mpcore.h" |
22 | +obj-$(CONFIG_NETDUINOPLUS2) += netduinoplus2.o | 25 | +#include "hw/intc/exynos4210_gic.h" |
23 | obj-$(CONFIG_NSERIES) += nseries.o | 26 | #include "target/arm/cpu-qom.h" |
24 | obj-$(CONFIG_SX1) += omap_sx1.o | 27 | #include "qom/object.h" |
25 | obj-$(CONFIG_CHEETAH) += palm.o | 28 | |
26 | diff --git a/hw/arm/netduinoplus2.c b/hw/arm/netduinoplus2.c | 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 | }; | ||
35 | |||
36 | #define TYPE_EXYNOS4210_SOC "exynos4210" | ||
37 | diff --git a/include/hw/intc/exynos4210_gic.h b/include/hw/intc/exynos4210_gic.h | ||
27 | new file mode 100644 | 38 | new file mode 100644 |
28 | index XXXXXXX..XXXXXXX | 39 | index XXXXXXX..XXXXXXX |
29 | --- /dev/null | 40 | --- /dev/null |
30 | +++ b/hw/arm/netduinoplus2.c | 41 | +++ b/include/hw/intc/exynos4210_gic.h |
31 | @@ -XXX,XX +XXX,XX @@ | 42 | @@ -XXX,XX +XXX,XX @@ |
32 | +/* | 43 | +/* |
33 | + * Netduino Plus 2 Machine Model | 44 | + * Samsung exynos4210 GIC implementation. Based on hw/arm_gic.c |
34 | + * | 45 | + * |
35 | + * Copyright (c) 2014 Alistair Francis <alistair@alistair23.me> | 46 | + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. |
47 | + * All rights reserved. | ||
36 | + * | 48 | + * |
37 | + * Permission is hereby granted, free of charge, to any person obtaining a copy | 49 | + * Evgeny Voevodin <e.voevodin@samsung.com> |
38 | + * of this software and associated documentation files (the "Software"), to deal | ||
39 | + * in the Software without restriction, including without limitation the rights | ||
40 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
41 | + * copies of the Software, and to permit persons to whom the Software is | ||
42 | + * furnished to do so, subject to the following conditions: | ||
43 | + * | 50 | + * |
44 | + * The above copyright notice and this permission notice shall be included in | 51 | + * This program is free software; you can redistribute it and/or modify it |
45 | + * all copies or substantial portions of the Software. | 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. | ||
46 | + * | 55 | + * |
47 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | 56 | + * This program is distributed in the hope that it will be useful, |
48 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 57 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
49 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | 58 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
50 | + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | 59 | + * See the GNU General Public License for more details. |
51 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | 60 | + * |
52 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | 61 | + * You should have received a copy of the GNU General Public License along |
53 | + * THE SOFTWARE. | 62 | + * with this program; if not, see <http://www.gnu.org/licenses/>. |
54 | + */ | 63 | + */ |
64 | +#ifndef HW_INTC_EXYNOS4210_GIC_H | ||
65 | +#define HW_INTC_EXYNOS4210_GIC_H | ||
55 | + | 66 | + |
56 | +#include "qemu/osdep.h" | 67 | +#include "hw/sysbus.h" |
57 | +#include "qapi/error.h" | ||
58 | +#include "hw/boards.h" | ||
59 | +#include "hw/qdev-properties.h" | ||
60 | +#include "qemu/error-report.h" | ||
61 | +#include "hw/arm/stm32f405_soc.h" | ||
62 | +#include "hw/arm/boot.h" | ||
63 | + | 68 | + |
64 | +static void netduinoplus2_init(MachineState *machine) | 69 | +#define TYPE_EXYNOS4210_GIC "exynos4210.gic" |
65 | +{ | 70 | +OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210GicState, EXYNOS4210_GIC) |
66 | + DeviceState *dev; | ||
67 | + | 71 | + |
68 | + dev = qdev_create(NULL, TYPE_STM32F405_SOC); | 72 | +#define EXYNOS4210_GIC_NCPUS 2 |
69 | + qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4")); | ||
70 | + object_property_set_bool(OBJECT(dev), true, "realized", &error_fatal); | ||
71 | + | 73 | + |
72 | + armv7m_load_kernel(ARM_CPU(first_cpu), | 74 | +struct Exynos4210GicState { |
73 | + machine->kernel_filename, | 75 | + SysBusDevice parent_obj; |
74 | + FLASH_SIZE); | ||
75 | +} | ||
76 | + | 76 | + |
77 | +static void netduinoplus2_machine_init(MachineClass *mc) | 77 | + MemoryRegion cpu_container; |
78 | +{ | 78 | + MemoryRegion dist_container; |
79 | + mc->desc = "Netduino Plus 2 Machine"; | 79 | + MemoryRegion cpu_alias[EXYNOS4210_GIC_NCPUS]; |
80 | + mc->init = netduinoplus2_init; | 80 | + MemoryRegion dist_alias[EXYNOS4210_GIC_NCPUS]; |
81 | +} | 81 | + uint32_t num_cpu; |
82 | + DeviceState *gic; | ||
83 | +}; | ||
82 | + | 84 | + |
83 | +DEFINE_MACHINE("netduinoplus2", netduinoplus2_machine_init) | 85 | +#endif |
86 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c | ||
87 | index XXXXXXX..XXXXXXX 100644 | ||
88 | --- a/hw/arm/exynos4210.c | ||
89 | +++ b/hw/arm/exynos4210.c | ||
90 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
91 | sysbus_create_simple("l2x0", EXYNOS4210_L2X0_BASE_ADDR, NULL); | ||
92 | |||
93 | /* External GIC */ | ||
94 | - dev = qdev_new("exynos4210.gic"); | ||
95 | - qdev_prop_set_uint32(dev, "num-cpu", EXYNOS4210_NCPUS); | ||
96 | - busdev = SYS_BUS_DEVICE(dev); | ||
97 | - sysbus_realize_and_unref(busdev, &error_fatal); | ||
98 | + qdev_prop_set_uint32(DEVICE(&s->ext_gic), "num-cpu", EXYNOS4210_NCPUS); | ||
99 | + busdev = SYS_BUS_DEVICE(&s->ext_gic); | ||
100 | + sysbus_realize(busdev, &error_fatal); | ||
101 | /* Map CPU interface */ | ||
102 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_GIC_CPU_BASE_ADDR); | ||
103 | /* Map Distributer interface */ | ||
104 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) | ||
105 | qdev_get_gpio_in(DEVICE(&s->cpu_irq_orgate[n]), 1)); | ||
106 | } | ||
107 | for (n = 0; n < EXYNOS4210_EXT_GIC_NIRQ; n++) { | ||
108 | - s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(dev, n); | ||
109 | + s->irqs.ext_gic_irq[n] = qdev_get_gpio_in(DEVICE(&s->ext_gic), n); | ||
110 | } | ||
111 | |||
112 | /* Internal Interrupt Combiner */ | ||
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); | ||
84 | diff --git a/MAINTAINERS b/MAINTAINERS | 163 | diff --git a/MAINTAINERS b/MAINTAINERS |
85 | index XXXXXXX..XXXXXXX 100644 | 164 | index XXXXXXX..XXXXXXX 100644 |
86 | --- a/MAINTAINERS | 165 | --- a/MAINTAINERS |
87 | +++ b/MAINTAINERS | 166 | +++ b/MAINTAINERS |
88 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> | 167 | @@ -XXX,XX +XXX,XX @@ M: Peter Maydell <peter.maydell@linaro.org> |
89 | S: Maintained | 168 | L: qemu-arm@nongnu.org |
90 | F: hw/arm/netduino2.c | 169 | S: Odd Fixes |
91 | 170 | F: hw/*/exynos* | |
92 | +Netduino Plus 2 | 171 | -F: include/hw/arm/exynos4210.h |
93 | +M: Alistair Francis <alistair@alistair23.me> | 172 | +F: include/hw/*/exynos* |
94 | +M: Peter Maydell <peter.maydell@linaro.org> | 173 | |
95 | +S: Maintained | 174 | Calxeda Highbank |
96 | +F: hw/arm/netduinoplus2.c | 175 | M: Rob Herring <robh@kernel.org> |
97 | + | ||
98 | SmartFusion2 | ||
99 | M: Subbaraya Sundeep <sundeep.lkml@gmail.com> | ||
100 | M: Peter Maydell <peter.maydell@linaro.org> | ||
101 | -- | 176 | -- |
102 | 2.20.1 | 177 | 2.25.1 |
103 | |||
104 | diff view generated by jsdifflib |
New 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. | ||
1 | 8 | ||
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 |
New patch | |||
---|---|---|---|
1 | The function exynos4210_combiner_get_gpioin() currently lives in | ||
2 | exynos4210_combiner.c, but it isn't really part of the combiner | ||
3 | device itself -- it is a function that implements the wiring up of | ||
4 | some interrupt sources to multiple combiner inputs. Move it to live | ||
5 | with the other SoC-level code in exynos4210.c, along with a few | ||
6 | macros previously defined in exynos4210.h which are now used only | ||
7 | in exynos4210.c. | ||
1 | 8 | ||
9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
10 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20220404154658.565020-11-peter.maydell@linaro.org | ||
12 | --- | ||
13 | include/hw/arm/exynos4210.h | 11 ----- | ||
14 | hw/arm/exynos4210.c | 82 +++++++++++++++++++++++++++++++++++ | ||
15 | hw/intc/exynos4210_combiner.c | 77 -------------------------------- | ||
16 | 3 files changed, 82 insertions(+), 88 deletions(-) | ||
17 | |||
18 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/hw/arm/exynos4210.h | ||
21 | +++ b/include/hw/arm/exynos4210.h | ||
22 | @@ -XXX,XX +XXX,XX @@ | ||
23 | #define EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ \ | ||
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 | } | ||
66 | |||
67 | +/* | ||
68 | + * Get Combiner input GPIO into irqs structure | ||
69 | + */ | ||
70 | +static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, | ||
71 | + DeviceState *dev, int ext) | ||
72 | +{ | ||
73 | + int n; | ||
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 | +} | ||
143 | + | ||
144 | static uint8_t chipid_and_omr[] = { 0x11, 0x02, 0x21, 0x43, | ||
145 | 0x09, 0x00, 0x00, 0x00 }; | ||
146 | |||
147 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c | ||
148 | index XXXXXXX..XXXXXXX 100644 | ||
149 | --- a/hw/intc/exynos4210_combiner.c | ||
150 | +++ b/hw/intc/exynos4210_combiner.c | ||
151 | @@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_exynos4210_combiner = { | ||
152 | } | ||
153 | }; | ||
154 | |||
155 | -/* | ||
156 | - * Get Combiner input GPIO into irqs structure | ||
157 | - */ | ||
158 | -void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, DeviceState *dev, | ||
159 | - int ext) | ||
160 | -{ | ||
161 | - int n; | ||
162 | - int bit; | ||
163 | - int max; | ||
164 | - qemu_irq *irq; | ||
165 | - | ||
166 | - max = ext ? EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ : | ||
167 | - EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; | ||
168 | - irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; | ||
169 | - | ||
170 | - /* | ||
171 | - * Some IRQs of Int/External Combiner are going to two Combiners groups, | ||
172 | - * so let split them. | ||
173 | - */ | ||
174 | - for (n = 0; n < max; n++) { | ||
175 | - | ||
176 | - bit = EXYNOS4210_COMBINER_GET_BIT_NUM(n); | ||
177 | - | ||
178 | - switch (n) { | ||
179 | - /* MDNIE_LCD1 INTG1 */ | ||
180 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 0) ... | ||
181 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 3): | ||
182 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
183 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(0, bit + 4)]); | ||
184 | - continue; | ||
185 | - | ||
186 | - /* TMU INTG3 */ | ||
187 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(3, 4): | ||
188 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
189 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(2, bit)]); | ||
190 | - continue; | ||
191 | - | ||
192 | - /* LCD1 INTG12 */ | ||
193 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 0) ... | ||
194 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 3): | ||
195 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
196 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(11, bit + 4)]); | ||
197 | - continue; | ||
198 | - | ||
199 | - /* Multi-Core Timer INTG12 */ | ||
200 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4) ... | ||
201 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 8): | ||
202 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
203 | - irq[EXYNOS4210_COMBINER_GET_IRQ_NUM(1, bit + 4)]); | ||
204 | - continue; | ||
205 | - | ||
206 | - /* Multi-Core Timer INTG35 */ | ||
207 | - case EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 4) ... | ||
208 | - EXYNOS4210_COMBINER_GET_IRQ_NUM(35, 8): | ||
209 | - irq[n] = qemu_irq_split(qdev_get_gpio_in(dev, n), | ||
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 | -- | ||
236 | 2.25.1 | diff view generated by jsdifflib |
New patch | |||
---|---|---|---|
1 | Delete a couple of #defines which are never used. | ||
1 | 2 | ||
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 |
New patch | |||
---|---|---|---|
1 | In exynos4210_init_board_irqs(), use the TYPE_SPLIT_IRQ device | ||
2 | instead of qemu_irq_split(). | ||
1 | 3 | ||
4 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
5 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
6 | Message-id: 20220404154658.565020-13-peter.maydell@linaro.org | ||
7 | --- | ||
8 | include/hw/arm/exynos4210.h | 9 ++++++++ | ||
9 | hw/arm/exynos4210.c | 41 +++++++++++++++++++++++++++++-------- | ||
10 | 2 files changed, 42 insertions(+), 8 deletions(-) | ||
11 | |||
12 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/include/hw/arm/exynos4210.h | ||
15 | +++ b/include/hw/arm/exynos4210.h | ||
16 | @@ -XXX,XX +XXX,XX @@ | ||
17 | #include "hw/sysbus.h" | ||
18 | #include "hw/cpu/a9mpcore.h" | ||
19 | #include "hw/intc/exynos4210_gic.h" | ||
20 | +#include "hw/core/split-irq.h" | ||
21 | #include "target/arm/cpu-qom.h" | ||
22 | #include "qom/object.h" | ||
23 | |||
24 | @@ -XXX,XX +XXX,XX @@ | ||
25 | |||
26 | #define EXYNOS4210_NUM_DMA 3 | ||
27 | |||
28 | +/* | ||
29 | + * We need one splitter for every external combiner input, plus | ||
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 | + | ||
35 | typedef struct Exynos4210Irq { | ||
36 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
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 | + } | ||
119 | + | ||
120 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); | ||
121 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); | ||
122 | } | ||
123 | -- | ||
124 | 2.25.1 | diff view generated by jsdifflib |
New 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.) | ||
1 | 8 | ||
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 |
New 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.) | ||
1 | 10 | ||
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 |
New patch | |||
---|---|---|---|
1 | The combiner_grp_to_gic_id[] array includes the EXT_GIC_ID_MCT_G0 | ||
2 | and EXT_GIC_ID_MCT_G1 multiple times. This means that we will | ||
3 | connect multiple IRQs up to the same external GIC input, which | ||
4 | is not permitted. We do the same thing in the code in | ||
5 | exynos4210_init_board_irqs() because the conditionals selecting | ||
6 | an irq_id in the first loop match multiple interrupt IDs. | ||
1 | 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 | |||
25 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
26 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
27 | Message-id: 20220404154658.565020-16-peter.maydell@linaro.org | ||
28 | --- | ||
29 | include/hw/arm/exynos4210.h | 2 +- | ||
30 | hw/arm/exynos4210.c | 12 +++++------- | ||
31 | 2 files changed, 6 insertions(+), 8 deletions(-) | ||
32 | |||
33 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
34 | index XXXXXXX..XXXXXXX 100644 | ||
35 | --- a/include/hw/arm/exynos4210.h | ||
36 | +++ b/include/hw/arm/exynos4210.h | ||
37 | @@ -XXX,XX +XXX,XX @@ | ||
38 | * one for every non-zero entry in combiner_grp_to_gic_id[]. | ||
39 | * We'll assert in exynos4210_init_board_irqs() if this is wrong. | ||
40 | */ | ||
41 | -#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 60) | ||
42 | +#define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 54) | ||
43 | |||
44 | typedef struct Exynos4210Irq { | ||
45 | qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; | ||
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 @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
51 | /* int combiner group 34 */ | ||
52 | { EXT_GIC_ID_ONENAND_AUDI, EXT_GIC_ID_NFC }, | ||
53 | /* int combiner group 35 */ | ||
54 | - { 0, 0, 0, EXT_GIC_ID_MCT_L1, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
55 | + { 0, 0, 0, EXT_GIC_ID_MCT_L1 }, | ||
56 | /* int combiner group 36 */ | ||
57 | { EXT_GIC_ID_MIXER }, | ||
58 | /* int combiner group 37 */ | ||
59 | @@ -XXX,XX +XXX,XX @@ combiner_grp_to_gic_id[64 - EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][8] = { | ||
60 | /* groups 38-50 */ | ||
61 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, { }, | ||
62 | /* int combiner group 51 */ | ||
63 | - { EXT_GIC_ID_MCT_L0, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
64 | + { EXT_GIC_ID_MCT_L0 }, | ||
65 | /* group 52 */ | ||
66 | { }, | ||
67 | /* int combiner group 53 */ | ||
68 | - { EXT_GIC_ID_WDT, 0, 0, 0, EXT_GIC_ID_MCT_G0, EXT_GIC_ID_MCT_G1 }, | ||
69 | + { EXT_GIC_ID_WDT }, | ||
70 | /* groups 54-63 */ | ||
71 | { }, { }, { }, { }, { }, { }, { }, { }, { }, { } | ||
72 | }; | ||
73 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
74 | |||
75 | for (n = 0; n < EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ; n++) { | ||
76 | irq_id = 0; | ||
77 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4) || | ||
78 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 4)) { | ||
79 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 4)) { | ||
80 | /* MCT_G0 is passed to External GIC */ | ||
81 | irq_id = EXT_GIC_ID_MCT_G0; | ||
82 | } | ||
83 | - if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5) || | ||
84 | - n == EXYNOS4210_COMBINER_GET_IRQ_NUM(12, 5)) { | ||
85 | + if (n == EXYNOS4210_COMBINER_GET_IRQ_NUM(1, 5)) { | ||
86 | /* MCT_G1 is passed to External and GIC */ | ||
87 | irq_id = EXT_GIC_ID_MCT_G1; | ||
88 | } | ||
89 | -- | ||
90 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | At this point, the function exynos4210_init_board_irqs() splits input |
---|---|---|---|
2 | 2 | IRQ lines to connect them to the input combiner, output combiner and | |
3 | We won't reuse the CPU IRQ/FIQ variables. Simplify by calling | 3 | external GIC. The function exynos4210_combiner_get_gpioin() splits |
4 | qdev_get_gpio_in() in place. | 4 | some of the combiner input lines further to connect them to multiple |
5 | 5 | different inputs on the combiner. | |
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | 6 | |
7 | Message-id: 20191230110953.25496-6-f4bug@amsat.org | 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 | |||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 39 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 40 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
41 | Message-id: 20220404154658.565020-17-peter.maydell@linaro.org | ||
10 | --- | 42 | --- |
11 | hw/arm/allwinner-a10.c | 9 ++++----- | 43 | include/hw/arm/exynos4210.h | 6 +- |
12 | 1 file changed, 4 insertions(+), 5 deletions(-) | 44 | hw/arm/exynos4210.c | 178 +++++++++++++++++++++++------------- |
13 | 45 | 2 files changed, 119 insertions(+), 65 deletions(-) | |
14 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c | 46 | |
47 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h | ||
15 | index XXXXXXX..XXXXXXX 100644 | 48 | index XXXXXXX..XXXXXXX 100644 |
16 | --- a/hw/arm/allwinner-a10.c | 49 | --- a/include/hw/arm/exynos4210.h |
17 | +++ b/hw/arm/allwinner-a10.c | 50 | +++ b/include/hw/arm/exynos4210.h |
18 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | 51 | @@ -XXX,XX +XXX,XX @@ |
52 | |||
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 | } | ||
208 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init_board_irqs(Exynos4210State *s) | ||
209 | irq_id = combiner_grp_to_gic_id[grp - | ||
210 | EXYNOS4210_MAX_EXT_COMBINER_OUT_IRQ][bit]; | ||
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) | ||
19 | { | 225 | { |
20 | AwA10State *s = AW_A10(dev); | 226 | int n; |
21 | SysBusDevice *sysbusdev; | 227 | - int bit; |
22 | - qemu_irq fiq, irq; | 228 | int max; |
23 | Error *err = NULL; | 229 | qemu_irq *irq; |
24 | 230 | ||
25 | object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); | 231 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_combiner_get_gpioin(Exynos4210Irq *irqs, |
26 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | 232 | EXYNOS4210_MAX_INT_COMBINER_IN_IRQ; |
27 | error_propagate(errp, err); | 233 | irq = ext ? irqs->ext_combiner_irq : irqs->int_combiner_irq; |
28 | return; | 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); | ||
29 | } | 294 | } |
30 | - irq = qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ); | 295 | } |
31 | - fiq = qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ); | ||
32 | |||
33 | object_property_set_bool(OBJECT(&s->intc), true, "realized", &err); | ||
34 | if (err != NULL) { | ||
35 | @@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp) | ||
36 | } | ||
37 | sysbusdev = SYS_BUS_DEVICE(&s->intc); | ||
38 | sysbus_mmio_map(sysbusdev, 0, AW_A10_PIC_REG_BASE); | ||
39 | - sysbus_connect_irq(sysbusdev, 0, irq); | ||
40 | - sysbus_connect_irq(sysbusdev, 1, fiq); | ||
41 | + sysbus_connect_irq(sysbusdev, 0, | ||
42 | + qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_IRQ)); | ||
43 | + sysbus_connect_irq(sysbusdev, 1, | ||
44 | + qdev_get_gpio_in(DEVICE(&s->cpu), ARM_CPU_FIQ)); | ||
45 | qdev_pass_gpios(DEVICE(&s->intc), dev, NULL); | ||
46 | |||
47 | object_property_set_bool(OBJECT(&s->timer), true, "realized", &err); | ||
48 | -- | 296 | -- |
49 | 2.20.1 | 297 | 2.25.1 |
50 | |||
51 | diff view generated by jsdifflib |
1 | From: Martin Kaiser <martin@kaiser.cx> | 1 | Switch the creation of the combiner devices to the new-style |
---|---|---|---|
2 | "embedded in state struct" approach, so we can easily refer | ||
3 | to the object elsewhere during realize. | ||
2 | 4 | ||
3 | Add an emulation for the RNGC random number generator and the compatible | 5 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
4 | RNGB variant. These peripherals are included (at least) in imx25 and | 6 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
5 | imx35 chipsets. | 7 | Message-id: 20220404154658.565020-18-peter.maydell@linaro.org |
8 | --- | ||
9 | include/hw/arm/exynos4210.h | 3 ++ | ||
10 | include/hw/intc/exynos4210_combiner.h | 57 +++++++++++++++++++++++++++ | ||
11 | hw/arm/exynos4210.c | 20 +++++----- | ||
12 | hw/intc/exynos4210_combiner.c | 31 +-------------- | ||
13 | 4 files changed, 72 insertions(+), 39 deletions(-) | ||
14 | create mode 100644 include/hw/intc/exynos4210_combiner.h | ||
6 | 15 | ||
7 | The emulation supports the initial self test, reseeding the prng and | 16 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
8 | reading random numbers. | ||
9 | |||
10 | Signed-off-by: Martin Kaiser <martin@kaiser.cx> | ||
11 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | ||
12 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | ||
13 | --- | ||
14 | hw/misc/Makefile.objs | 1 + | ||
15 | include/hw/arm/fsl-imx25.h | 5 + | ||
16 | include/hw/misc/imx_rngc.h | 35 +++++ | ||
17 | hw/arm/fsl-imx25.c | 11 ++ | ||
18 | hw/misc/imx_rngc.c | 278 +++++++++++++++++++++++++++++++++++++ | ||
19 | 5 files changed, 330 insertions(+) | ||
20 | create mode 100644 include/hw/misc/imx_rngc.h | ||
21 | create mode 100644 hw/misc/imx_rngc.c | ||
22 | |||
23 | diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs | ||
24 | index XXXXXXX..XXXXXXX 100644 | 17 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/hw/misc/Makefile.objs | 18 | --- a/include/hw/arm/exynos4210.h |
26 | +++ b/hw/misc/Makefile.objs | 19 | +++ b/include/hw/arm/exynos4210.h |
27 | @@ -XXX,XX +XXX,XX @@ common-obj-$(CONFIG_IMX) += imx7_ccm.o | ||
28 | common-obj-$(CONFIG_IMX) += imx2_wdt.o | ||
29 | common-obj-$(CONFIG_IMX) += imx7_snvs.o | ||
30 | common-obj-$(CONFIG_IMX) += imx7_gpr.o | ||
31 | +common-obj-$(CONFIG_IMX) += imx_rngc.o | ||
32 | common-obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o | ||
33 | common-obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o | ||
34 | common-obj-$(CONFIG_MAINSTONE) += mst_fpga.o | ||
35 | diff --git a/include/hw/arm/fsl-imx25.h b/include/hw/arm/fsl-imx25.h | ||
36 | index XXXXXXX..XXXXXXX 100644 | ||
37 | --- a/include/hw/arm/fsl-imx25.h | ||
38 | +++ b/include/hw/arm/fsl-imx25.h | ||
39 | @@ -XXX,XX +XXX,XX @@ | 20 | @@ -XXX,XX +XXX,XX @@ |
40 | #include "hw/timer/imx_gpt.h" | 21 | #include "hw/sysbus.h" |
41 | #include "hw/timer/imx_epit.h" | 22 | #include "hw/cpu/a9mpcore.h" |
42 | #include "hw/net/imx_fec.h" | 23 | #include "hw/intc/exynos4210_gic.h" |
43 | +#include "hw/misc/imx_rngc.h" | 24 | +#include "hw/intc/exynos4210_combiner.h" |
44 | #include "hw/i2c/imx_i2c.h" | 25 | #include "hw/core/split-irq.h" |
45 | #include "hw/gpio/imx_gpio.h" | 26 | #include "target/arm/cpu-qom.h" |
46 | #include "exec/memory.h" | 27 | #include "qom/object.h" |
47 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX25State { | 28 | @@ -XXX,XX +XXX,XX @@ struct Exynos4210State { |
48 | IMXGPTState gpt[FSL_IMX25_NUM_GPTS]; | 29 | qemu_or_irq cpu_irq_orgate[EXYNOS4210_NCPUS]; |
49 | IMXEPITState epit[FSL_IMX25_NUM_EPITS]; | 30 | A9MPPrivState a9mpcore; |
50 | IMXFECState fec; | 31 | Exynos4210GicState ext_gic; |
51 | + IMXRNGCState rngc; | 32 | + Exynos4210CombinerState int_combiner; |
52 | IMXI2CState i2c[FSL_IMX25_NUM_I2CS]; | 33 | + Exynos4210CombinerState ext_combiner; |
53 | IMXGPIOState gpio[FSL_IMX25_NUM_GPIOS]; | 34 | SplitIRQ splitter[EXYNOS4210_NUM_SPLITTERS]; |
54 | MemoryRegion rom[2]; | 35 | }; |
55 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX25State { | 36 | |
56 | #define FSL_IMX25_GPIO4_SIZE 0x4000 | 37 | diff --git a/include/hw/intc/exynos4210_combiner.h b/include/hw/intc/exynos4210_combiner.h |
57 | #define FSL_IMX25_GPIO3_ADDR 0x53FA4000 | ||
58 | #define FSL_IMX25_GPIO3_SIZE 0x4000 | ||
59 | +#define FSL_IMX25_RNGC_ADDR 0x53FB0000 | ||
60 | +#define FSL_IMX25_RNGC_SIZE 0x4000 | ||
61 | #define FSL_IMX25_GPIO1_ADDR 0x53FCC000 | ||
62 | #define FSL_IMX25_GPIO1_SIZE 0x4000 | ||
63 | #define FSL_IMX25_GPIO2_ADDR 0x53FD0000 | ||
64 | @@ -XXX,XX +XXX,XX @@ typedef struct FslIMX25State { | ||
65 | #define FSL_IMX25_EPIT1_IRQ 28 | ||
66 | #define FSL_IMX25_EPIT2_IRQ 27 | ||
67 | #define FSL_IMX25_FEC_IRQ 57 | ||
68 | +#define FSL_IMX25_RNGC_IRQ 22 | ||
69 | #define FSL_IMX25_I2C1_IRQ 3 | ||
70 | #define FSL_IMX25_I2C2_IRQ 4 | ||
71 | #define FSL_IMX25_I2C3_IRQ 10 | ||
72 | diff --git a/include/hw/misc/imx_rngc.h b/include/hw/misc/imx_rngc.h | ||
73 | new file mode 100644 | 38 | new file mode 100644 |
74 | index XXXXXXX..XXXXXXX | 39 | index XXXXXXX..XXXXXXX |
75 | --- /dev/null | 40 | --- /dev/null |
76 | +++ b/include/hw/misc/imx_rngc.h | 41 | +++ b/include/hw/intc/exynos4210_combiner.h |
77 | @@ -XXX,XX +XXX,XX @@ | 42 | @@ -XXX,XX +XXX,XX @@ |
78 | +/* | 43 | +/* |
79 | + * Freescale i.MX RNGC emulation | 44 | + * Samsung exynos4210 Interrupt Combiner |
80 | + * | 45 | + * |
81 | + * Copyright (C) 2020 Martin Kaiser <martin@kaiser.cx> | 46 | + * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. |
47 | + * All rights reserved. | ||
82 | + * | 48 | + * |
83 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | 49 | + * Evgeny Voevodin <e.voevodin@samsung.com> |
84 | + * See the COPYING file in the top-level directory. | 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/>. | ||
85 | + */ | 63 | + */ |
86 | + | 64 | + |
87 | +#ifndef IMX_RNGC_H | 65 | +#ifndef HW_INTC_EXYNOS4210_COMBINER |
88 | +#define IMX_RNGC_H | 66 | +#define HW_INTC_EXYNOS4210_COMBINER |
89 | + | 67 | + |
90 | +#include "hw/sysbus.h" | 68 | +#include "hw/sysbus.h" |
91 | + | 69 | + |
92 | +#define TYPE_IMX_RNGC "imx.rngc" | 70 | +/* |
93 | +#define IMX_RNGC(obj) OBJECT_CHECK(IMXRNGCState, (obj), TYPE_IMX_RNGC) | 71 | + * State for each output signal of internal combiner |
72 | + */ | ||
73 | +typedef struct CombinerGroupState { | ||
74 | + uint8_t src_mask; /* 1 - source enabled, 0 - disabled */ | ||
75 | + uint8_t src_pending; /* Pending source interrupts before masking */ | ||
76 | +} CombinerGroupState; | ||
94 | + | 77 | + |
95 | +typedef struct IMXRNGCState { | 78 | +#define TYPE_EXYNOS4210_COMBINER "exynos4210.combiner" |
96 | + /*< private >*/ | 79 | +OBJECT_DECLARE_SIMPLE_TYPE(Exynos4210CombinerState, EXYNOS4210_COMBINER) |
80 | + | ||
81 | +/* Number of groups and total number of interrupts for the internal combiner */ | ||
82 | +#define IIC_NGRP 64 | ||
83 | +#define IIC_NIRQ (IIC_NGRP * 8) | ||
84 | +#define IIC_REGSET_SIZE 0x41 | ||
85 | + | ||
86 | +struct Exynos4210CombinerState { | ||
97 | + SysBusDevice parent_obj; | 87 | + SysBusDevice parent_obj; |
98 | + | 88 | + |
99 | + /*< public >*/ | 89 | + MemoryRegion iomem; |
100 | + MemoryRegion iomem; | ||
101 | + | 90 | + |
102 | + uint8_t op_self_test; | 91 | + struct CombinerGroupState group[IIC_NGRP]; |
103 | + uint8_t op_seed; | 92 | + uint32_t reg_set[IIC_REGSET_SIZE]; |
104 | + uint8_t mask; | 93 | + uint32_t icipsr[2]; |
105 | + bool auto_seed; | 94 | + uint32_t external; /* 1 means that this combiner is external */ |
106 | + | 95 | + |
107 | + QEMUBH *self_test_bh; | 96 | + qemu_irq output_irq[IIC_NGRP]; |
108 | + QEMUBH *seed_bh; | ||
109 | + qemu_irq irq; | ||
110 | +} IMXRNGCState; | ||
111 | + | ||
112 | +#endif /* IMX_RNGC_H */ | ||
113 | diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c | ||
114 | index XXXXXXX..XXXXXXX 100644 | ||
115 | --- a/hw/arm/fsl-imx25.c | ||
116 | +++ b/hw/arm/fsl-imx25.c | ||
117 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx25_init(Object *obj) | ||
118 | |||
119 | sysbus_init_child_obj(obj, "fec", &s->fec, sizeof(s->fec), TYPE_IMX_FEC); | ||
120 | |||
121 | + sysbus_init_child_obj(obj, "rngc", &s->rngc, sizeof(s->rngc), | ||
122 | + TYPE_IMX_RNGC); | ||
123 | + | ||
124 | for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) { | ||
125 | sysbus_init_child_obj(obj, "i2c[*]", &s->i2c[i], sizeof(s->i2c[i]), | ||
126 | TYPE_IMX_I2C); | ||
127 | @@ -XXX,XX +XXX,XX @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) | ||
128 | sysbus_connect_irq(SYS_BUS_DEVICE(&s->fec), 0, | ||
129 | qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_FEC_IRQ)); | ||
130 | |||
131 | + object_property_set_bool(OBJECT(&s->rngc), true, "realized", &err); | ||
132 | + if (err) { | ||
133 | + error_propagate(errp, err); | ||
134 | + return; | ||
135 | + } | ||
136 | + sysbus_mmio_map(SYS_BUS_DEVICE(&s->rngc), 0, FSL_IMX25_RNGC_ADDR); | ||
137 | + sysbus_connect_irq(SYS_BUS_DEVICE(&s->rngc), 0, | ||
138 | + qdev_get_gpio_in(DEVICE(&s->avic), FSL_IMX25_RNGC_IRQ)); | ||
139 | |||
140 | /* Initialize all I2C */ | ||
141 | for (i = 0; i < FSL_IMX25_NUM_I2CS; i++) { | ||
142 | diff --git a/hw/misc/imx_rngc.c b/hw/misc/imx_rngc.c | ||
143 | new file mode 100644 | ||
144 | index XXXXXXX..XXXXXXX | ||
145 | --- /dev/null | ||
146 | +++ b/hw/misc/imx_rngc.c | ||
147 | @@ -XXX,XX +XXX,XX @@ | ||
148 | +/* | ||
149 | + * Freescale i.MX RNGC emulation | ||
150 | + * | ||
151 | + * Copyright (C) 2020 Martin Kaiser <martin@kaiser.cx> | ||
152 | + * | ||
153 | + * This work is licensed under the terms of the GNU GPL, version 2 or later. | ||
154 | + * See the COPYING file in the top-level directory. | ||
155 | + * | ||
156 | + * This driver provides the minimum functionality to initialize and seed | ||
157 | + * an rngc and to read random numbers. The rngb that is found in imx25 | ||
158 | + * chipsets is also supported. | ||
159 | + */ | ||
160 | + | ||
161 | +#include "qemu/osdep.h" | ||
162 | +#include "qemu/main-loop.h" | ||
163 | +#include "qemu/module.h" | ||
164 | +#include "qemu/log.h" | ||
165 | +#include "qemu/guest-random.h" | ||
166 | +#include "hw/irq.h" | ||
167 | +#include "hw/misc/imx_rngc.h" | ||
168 | +#include "migration/vmstate.h" | ||
169 | + | ||
170 | +#define RNGC_NAME "i.MX RNGC" | ||
171 | + | ||
172 | +#define RNGC_VER_ID 0x00 | ||
173 | +#define RNGC_COMMAND 0x04 | ||
174 | +#define RNGC_CONTROL 0x08 | ||
175 | +#define RNGC_STATUS 0x0C | ||
176 | +#define RNGC_FIFO 0x14 | ||
177 | + | ||
178 | +/* These version info are reported by the rngb in an imx258 chip. */ | ||
179 | +#define RNG_TYPE_RNGB 0x1 | ||
180 | +#define V_MAJ 0x2 | ||
181 | +#define V_MIN 0x40 | ||
182 | + | ||
183 | +#define RNGC_CMD_BIT_SW_RST 0x40 | ||
184 | +#define RNGC_CMD_BIT_CLR_ERR 0x20 | ||
185 | +#define RNGC_CMD_BIT_CLR_INT 0x10 | ||
186 | +#define RNGC_CMD_BIT_SEED 0x02 | ||
187 | +#define RNGC_CMD_BIT_SELF_TEST 0x01 | ||
188 | + | ||
189 | +#define RNGC_CTRL_BIT_MASK_ERR 0x40 | ||
190 | +#define RNGC_CTRL_BIT_MASK_DONE 0x20 | ||
191 | +#define RNGC_CTRL_BIT_AUTO_SEED 0x10 | ||
192 | + | ||
193 | +/* the current status for self-test and seed operations */ | ||
194 | +#define OP_IDLE 0 | ||
195 | +#define OP_RUN 1 | ||
196 | +#define OP_DONE 2 | ||
197 | + | ||
198 | +static uint64_t imx_rngc_read(void *opaque, hwaddr offset, unsigned size) | ||
199 | +{ | ||
200 | + IMXRNGCState *s = IMX_RNGC(opaque); | ||
201 | + uint64_t val = 0; | ||
202 | + | ||
203 | + switch (offset) { | ||
204 | + case RNGC_VER_ID: | ||
205 | + val |= RNG_TYPE_RNGB << 28 | V_MAJ << 8 | V_MIN; | ||
206 | + break; | ||
207 | + | ||
208 | + case RNGC_COMMAND: | ||
209 | + if (s->op_seed == OP_RUN) { | ||
210 | + val |= RNGC_CMD_BIT_SEED; | ||
211 | + } | ||
212 | + if (s->op_self_test == OP_RUN) { | ||
213 | + val |= RNGC_CMD_BIT_SELF_TEST; | ||
214 | + } | ||
215 | + break; | ||
216 | + | ||
217 | + case RNGC_CONTROL: | ||
218 | + /* | ||
219 | + * The CTL_ACC and VERIF_MODE bits are not supported yet. | ||
220 | + * They read as 0. | ||
221 | + */ | ||
222 | + val |= s->mask; | ||
223 | + if (s->auto_seed) { | ||
224 | + val |= RNGC_CTRL_BIT_AUTO_SEED; | ||
225 | + } | ||
226 | + /* | ||
227 | + * We don't have an internal fifo like the real hardware. | ||
228 | + * There's no need for strategy to handle fifo underflows. | ||
229 | + * We return the FIFO_UFLOW_RESPONSE bits as 0. | ||
230 | + */ | ||
231 | + break; | ||
232 | + | ||
233 | + case RNGC_STATUS: | ||
234 | + /* | ||
235 | + * We never report any statistics test or self-test errors or any | ||
236 | + * other errors. STAT_TEST_PF, ST_PF and ERROR are always 0. | ||
237 | + */ | ||
238 | + | ||
239 | + /* | ||
240 | + * We don't have an internal fifo, see above. Therefore, we | ||
241 | + * report back the default fifo size (5 32-bit words) and | ||
242 | + * indicate that our fifo is always full. | ||
243 | + */ | ||
244 | + val |= 5 << 12 | 5 << 8; | ||
245 | + | ||
246 | + /* We always have a new seed available. */ | ||
247 | + val |= 1 << 6; | ||
248 | + | ||
249 | + if (s->op_seed == OP_DONE) { | ||
250 | + val |= 1 << 5; | ||
251 | + } | ||
252 | + if (s->op_self_test == OP_DONE) { | ||
253 | + val |= 1 << 4; | ||
254 | + } | ||
255 | + if (s->op_seed == OP_RUN || s->op_self_test == OP_RUN) { | ||
256 | + /* | ||
257 | + * We're busy if self-test is running or if we're | ||
258 | + * seeding the prng. | ||
259 | + */ | ||
260 | + val |= 1 << 1; | ||
261 | + } else { | ||
262 | + /* | ||
263 | + * We're ready to provide secure random numbers whenever | ||
264 | + * we're not busy. | ||
265 | + */ | ||
266 | + val |= 1; | ||
267 | + } | ||
268 | + break; | ||
269 | + | ||
270 | + case RNGC_FIFO: | ||
271 | + qemu_guest_getrandom_nofail(&val, sizeof(val)); | ||
272 | + break; | ||
273 | + } | ||
274 | + | ||
275 | + return val; | ||
276 | +} | ||
277 | + | ||
278 | +static void imx_rngc_do_reset(IMXRNGCState *s) | ||
279 | +{ | ||
280 | + s->op_self_test = OP_IDLE; | ||
281 | + s->op_seed = OP_IDLE; | ||
282 | + s->mask = 0; | ||
283 | + s->auto_seed = false; | ||
284 | +} | ||
285 | + | ||
286 | +static void imx_rngc_write(void *opaque, hwaddr offset, uint64_t value, | ||
287 | + unsigned size) | ||
288 | +{ | ||
289 | + IMXRNGCState *s = IMX_RNGC(opaque); | ||
290 | + | ||
291 | + switch (offset) { | ||
292 | + case RNGC_COMMAND: | ||
293 | + if (value & RNGC_CMD_BIT_SW_RST) { | ||
294 | + imx_rngc_do_reset(s); | ||
295 | + } | ||
296 | + | ||
297 | + /* | ||
298 | + * For now, both CLR_ERR and CLR_INT clear the interrupt. We | ||
299 | + * don't report any errors yet. | ||
300 | + */ | ||
301 | + if (value & (RNGC_CMD_BIT_CLR_ERR | RNGC_CMD_BIT_CLR_INT)) { | ||
302 | + qemu_irq_lower(s->irq); | ||
303 | + } | ||
304 | + | ||
305 | + if (value & RNGC_CMD_BIT_SEED) { | ||
306 | + s->op_seed = OP_RUN; | ||
307 | + qemu_bh_schedule(s->seed_bh); | ||
308 | + } | ||
309 | + | ||
310 | + if (value & RNGC_CMD_BIT_SELF_TEST) { | ||
311 | + s->op_self_test = OP_RUN; | ||
312 | + qemu_bh_schedule(s->self_test_bh); | ||
313 | + } | ||
314 | + break; | ||
315 | + | ||
316 | + case RNGC_CONTROL: | ||
317 | + /* | ||
318 | + * The CTL_ACC and VERIF_MODE bits are not supported yet. | ||
319 | + * We ignore them if they're set by the caller. | ||
320 | + */ | ||
321 | + | ||
322 | + if (value & RNGC_CTRL_BIT_MASK_ERR) { | ||
323 | + s->mask |= RNGC_CTRL_BIT_MASK_ERR; | ||
324 | + } else { | ||
325 | + s->mask &= ~RNGC_CTRL_BIT_MASK_ERR; | ||
326 | + } | ||
327 | + | ||
328 | + if (value & RNGC_CTRL_BIT_MASK_DONE) { | ||
329 | + s->mask |= RNGC_CTRL_BIT_MASK_DONE; | ||
330 | + } else { | ||
331 | + s->mask &= ~RNGC_CTRL_BIT_MASK_DONE; | ||
332 | + } | ||
333 | + | ||
334 | + if (value & RNGC_CTRL_BIT_AUTO_SEED) { | ||
335 | + s->auto_seed = true; | ||
336 | + } else { | ||
337 | + s->auto_seed = false; | ||
338 | + } | ||
339 | + break; | ||
340 | + } | ||
341 | +} | ||
342 | + | ||
343 | +static const MemoryRegionOps imx_rngc_ops = { | ||
344 | + .read = imx_rngc_read, | ||
345 | + .write = imx_rngc_write, | ||
346 | + .endianness = DEVICE_NATIVE_ENDIAN, | ||
347 | +}; | 97 | +}; |
348 | + | 98 | + |
349 | +static void imx_rngc_self_test(void *opaque) | 99 | +#endif |
350 | +{ | 100 | diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c |
351 | + IMXRNGCState *s = IMX_RNGC(opaque); | 101 | index XXXXXXX..XXXXXXX 100644 |
352 | + | 102 | --- a/hw/arm/exynos4210.c |
353 | + s->op_self_test = OP_DONE; | 103 | +++ b/hw/arm/exynos4210.c |
354 | + if (!(s->mask & RNGC_CTRL_BIT_MASK_DONE)) { | 104 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_realize(DeviceState *socdev, Error **errp) |
355 | + qemu_irq_raise(s->irq); | 105 | } |
356 | + } | 106 | |
357 | +} | 107 | /* Internal Interrupt Combiner */ |
358 | + | 108 | - dev = qdev_new("exynos4210.combiner"); |
359 | +static void imx_rngc_seed(void *opaque) | 109 | - busdev = SYS_BUS_DEVICE(dev); |
360 | +{ | 110 | - sysbus_realize_and_unref(busdev, &error_fatal); |
361 | + IMXRNGCState *s = IMX_RNGC(opaque); | 111 | + busdev = SYS_BUS_DEVICE(&s->int_combiner); |
362 | + | 112 | + sysbus_realize(busdev, &error_fatal); |
363 | + s->op_seed = OP_DONE; | 113 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { |
364 | + if (!(s->mask & RNGC_CTRL_BIT_MASK_DONE)) { | 114 | sysbus_connect_irq(busdev, n, |
365 | + qemu_irq_raise(s->irq); | 115 | qdev_get_gpio_in(DEVICE(&s->a9mpcore), n)); |
366 | + } | 116 | } |
367 | +} | 117 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 0); |
368 | + | 118 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->int_combiner), 0); |
369 | +static void imx_rngc_realize(DeviceState *dev, Error **errp) | 119 | sysbus_mmio_map(busdev, 0, EXYNOS4210_INT_COMBINER_BASE_ADDR); |
370 | +{ | 120 | |
371 | + IMXRNGCState *s = IMX_RNGC(dev); | 121 | /* External Interrupt Combiner */ |
372 | + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); | 122 | - dev = qdev_new("exynos4210.combiner"); |
373 | + | 123 | - qdev_prop_set_uint32(dev, "external", 1); |
374 | + memory_region_init_io(&s->iomem, OBJECT(s), &imx_rngc_ops, s, | 124 | - busdev = SYS_BUS_DEVICE(dev); |
375 | + TYPE_IMX_RNGC, 0x1000); | 125 | - sysbus_realize_and_unref(busdev, &error_fatal); |
376 | + sysbus_init_mmio(sbd, &s->iomem); | 126 | + qdev_prop_set_uint32(DEVICE(&s->ext_combiner), "external", 1); |
377 | + | 127 | + busdev = SYS_BUS_DEVICE(&s->ext_combiner); |
378 | + sysbus_init_irq(sbd, &s->irq); | 128 | + sysbus_realize(busdev, &error_fatal); |
379 | + s->self_test_bh = qemu_bh_new(imx_rngc_self_test, s); | 129 | for (n = 0; n < EXYNOS4210_MAX_INT_COMBINER_OUT_IRQ; n++) { |
380 | + s->seed_bh = qemu_bh_new(imx_rngc_seed, s); | 130 | sysbus_connect_irq(busdev, n, qdev_get_gpio_in(DEVICE(&s->ext_gic), n)); |
381 | +} | 131 | } |
382 | + | 132 | - exynos4210_combiner_get_gpioin(&s->irqs, dev, 1); |
383 | +static void imx_rngc_reset(DeviceState *dev) | 133 | + exynos4210_combiner_get_gpioin(&s->irqs, DEVICE(&s->ext_combiner), 1); |
384 | +{ | 134 | sysbus_mmio_map(busdev, 0, EXYNOS4210_EXT_COMBINER_BASE_ADDR); |
385 | + IMXRNGCState *s = IMX_RNGC(dev); | 135 | |
386 | + | 136 | /* Initialize board IRQs. */ |
387 | + imx_rngc_do_reset(s); | 137 | @@ -XXX,XX +XXX,XX @@ static void exynos4210_init(Object *obj) |
388 | +} | 138 | |
389 | + | 139 | object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); |
390 | +static const VMStateDescription vmstate_imx_rngc = { | 140 | object_initialize_child(obj, "ext-gic", &s->ext_gic, TYPE_EXYNOS4210_GIC); |
391 | + .name = RNGC_NAME, | 141 | + object_initialize_child(obj, "int-combiner", &s->int_combiner, |
392 | + .version_id = 1, | 142 | + TYPE_EXYNOS4210_COMBINER); |
393 | + .minimum_version_id = 1, | 143 | + object_initialize_child(obj, "ext-combiner", &s->ext_combiner, |
394 | + .fields = (VMStateField[]) { | 144 | + TYPE_EXYNOS4210_COMBINER); |
395 | + VMSTATE_UINT8(op_self_test, IMXRNGCState), | 145 | } |
396 | + VMSTATE_UINT8(op_seed, IMXRNGCState), | 146 | |
397 | + VMSTATE_UINT8(mask, IMXRNGCState), | 147 | static void exynos4210_class_init(ObjectClass *klass, void *data) |
398 | + VMSTATE_BOOL(auto_seed, IMXRNGCState), | 148 | diff --git a/hw/intc/exynos4210_combiner.c b/hw/intc/exynos4210_combiner.c |
399 | + VMSTATE_END_OF_LIST() | 149 | index XXXXXXX..XXXXXXX 100644 |
400 | + } | 150 | --- a/hw/intc/exynos4210_combiner.c |
401 | +}; | 151 | +++ b/hw/intc/exynos4210_combiner.c |
402 | + | 152 | @@ -XXX,XX +XXX,XX @@ |
403 | +static void imx_rngc_class_init(ObjectClass *klass, void *data) | 153 | #include "hw/sysbus.h" |
404 | +{ | 154 | #include "migration/vmstate.h" |
405 | + DeviceClass *dc = DEVICE_CLASS(klass); | 155 | #include "qemu/module.h" |
406 | + | 156 | - |
407 | + dc->realize = imx_rngc_realize; | 157 | +#include "hw/intc/exynos4210_combiner.h" |
408 | + dc->reset = imx_rngc_reset; | 158 | #include "hw/arm/exynos4210.h" |
409 | + dc->desc = RNGC_NAME, | 159 | #include "hw/hw.h" |
410 | + dc->vmsd = &vmstate_imx_rngc; | 160 | #include "hw/irq.h" |
411 | +} | 161 | @@ -XXX,XX +XXX,XX @@ |
412 | + | 162 | #define DPRINTF(fmt, ...) do {} while (0) |
413 | +static const TypeInfo imx_rngc_info = { | 163 | #endif |
414 | + .name = TYPE_IMX_RNGC, | 164 | |
415 | + .parent = TYPE_SYS_BUS_DEVICE, | 165 | -#define IIC_NGRP 64 /* Internal Interrupt Combiner |
416 | + .instance_size = sizeof(IMXRNGCState), | 166 | - Groups number */ |
417 | + .class_init = imx_rngc_class_init, | 167 | -#define IIC_NIRQ (IIC_NGRP * 8)/* Internal Interrupt Combiner |
418 | +}; | 168 | - Interrupts number */ |
419 | + | 169 | #define IIC_REGION_SIZE 0x108 /* Size of memory mapped region */ |
420 | +static void imx_rngc_register_types(void) | 170 | -#define IIC_REGSET_SIZE 0x41 |
421 | +{ | 171 | - |
422 | + type_register_static(&imx_rngc_info); | 172 | -/* |
423 | +} | 173 | - * State for each output signal of internal combiner |
424 | + | 174 | - */ |
425 | +type_init(imx_rngc_register_types) | 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", | ||
426 | -- | 198 | -- |
427 | 2.20.1 | 199 | 2.25.1 |
428 | |||
429 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | The only time we use the int_combiner_irq[] and ext_combiner_irq[] |
---|---|---|---|
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. | ||
2 | 9 | ||
3 | These definitions are specific to the A10 SoC and don't need | 10 | Since these are the only two remaining elements of Exynos4210Irq, |
4 | to be exported to the different Allwinner peripherals. | 11 | we can remove that struct entirely. |
5 | 12 | ||
6 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
7 | Message-id: 20191230110953.25496-4-f4bug@amsat.org | ||
8 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 14 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> |
15 | Message-id: 20220404154658.565020-19-peter.maydell@linaro.org | ||
10 | --- | 16 | --- |
11 | include/hw/arm/allwinner-a10.h | 6 ------ | 17 | include/hw/arm/exynos4210.h | 6 ------ |
12 | hw/arm/allwinner-a10.c | 6 ++++++ | 18 | hw/arm/exynos4210.c | 34 ++++++++-------------------------- |
13 | 2 files changed, 6 insertions(+), 6 deletions(-) | 19 | 2 files changed, 8 insertions(+), 32 deletions(-) |
14 | 20 | ||
15 | diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h | 21 | diff --git a/include/hw/arm/exynos4210.h b/include/hw/arm/exynos4210.h |
16 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/include/hw/arm/allwinner-a10.h | 23 | --- a/include/hw/arm/exynos4210.h |
18 | +++ b/include/hw/arm/allwinner-a10.h | 24 | +++ b/include/hw/arm/exynos4210.h |
19 | @@ -XXX,XX +XXX,XX @@ | 25 | @@ -XXX,XX +XXX,XX @@ |
20 | #include "target/arm/cpu.h" | 26 | */ |
21 | 27 | #define EXYNOS4210_NUM_SPLITTERS (EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ + 38) | |
22 | 28 | ||
23 | -#define AW_A10_PIC_REG_BASE 0x01c20400 | 29 | -typedef struct Exynos4210Irq { |
24 | -#define AW_A10_PIT_REG_BASE 0x01c20c00 | 30 | - qemu_irq int_combiner_irq[EXYNOS4210_MAX_INT_COMBINER_IN_IRQ]; |
25 | -#define AW_A10_UART0_REG_BASE 0x01c28000 | 31 | - qemu_irq ext_combiner_irq[EXYNOS4210_MAX_EXT_COMBINER_IN_IRQ]; |
26 | -#define AW_A10_EMAC_BASE 0x01c0b000 | 32 | -} Exynos4210Irq; |
27 | -#define AW_A10_SATA_BASE 0x01c18000 | ||
28 | - | 33 | - |
29 | #define AW_A10_SDRAM_BASE 0x40000000 | 34 | struct Exynos4210State { |
30 | 35 | /*< private >*/ | |
31 | #define TYPE_AW_A10 "allwinner-a10" | 36 | SysBusDevice parent_obj; |
32 | diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c | 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 | ||
33 | index XXXXXXX..XXXXXXX 100644 | 44 | index XXXXXXX..XXXXXXX 100644 |
34 | --- a/hw/arm/allwinner-a10.c | 45 | --- a/hw/arm/exynos4210.c |
35 | +++ b/hw/arm/allwinner-a10.c | 46 | +++ b/hw/arm/exynos4210.c |
36 | @@ -XXX,XX +XXX,XX @@ | 47 | @@ -XXX,XX +XXX,XX @@ static int mapline_size(const int *mapline) |
37 | #include "hw/misc/unimp.h" | 48 | static void exynos4210_init_board_irqs(Exynos4210State *s) |
38 | #include "sysemu/sysemu.h" | ||
39 | |||
40 | +#define AW_A10_PIC_REG_BASE 0x01c20400 | ||
41 | +#define AW_A10_PIT_REG_BASE 0x01c20c00 | ||
42 | +#define AW_A10_UART0_REG_BASE 0x01c28000 | ||
43 | +#define AW_A10_EMAC_BASE 0x01c0b000 | ||
44 | +#define AW_A10_SATA_BASE 0x01c18000 | ||
45 | + | ||
46 | static void aw_a10_init(Object *obj) | ||
47 | { | 49 | { |
48 | AwA10State *s = AW_A10(obj); | 50 | uint32_t grp, bit, irq_id, n; |
51 | - Exynos4210Irq *is = &s->irqs; | ||
52 | DeviceState *extgicdev = DEVICE(&s->ext_gic); | ||
53 | + DeviceState *intcdev = DEVICE(&s->int_combiner); | ||
54 | + DeviceState *extcdev = DEVICE(&s->ext_combiner); | ||
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. */ | ||
49 | -- | 127 | -- |
50 | 2.20.1 | 128 | 2.25.1 |
51 | |||
52 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | This test boots a Linux kernel on a CubieBoard and verify | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | the serial output is working. | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | 5 | Message-id: 20220324181557.203805-2-zongyuan.li@smartx.com | |
6 | The kernel image and DeviceTree blob are built by the Armbian | ||
7 | project (based on Debian): | ||
8 | https://docs.armbian.com/Developer-Guide_Build-Preparation/ | ||
9 | |||
10 | The cpio image used comes from the linux-build-test project: | ||
11 | https://github.com/groeck/linux-build-test | ||
12 | |||
13 | If ARM is a target being built, "make check-acceptance" will | ||
14 | automatically include this test by the use of the "arch:arm" tags. | ||
15 | |||
16 | Alternatively, this test can be run using: | ||
17 | |||
18 | $ avocado --show=console run -t machine:cubieboard tests/acceptance/boot_linux_console.py | ||
19 | console: Uncompressing Linux... done, booting the kernel. | ||
20 | console: Booting Linux on physical CPU 0x0 | ||
21 | console: Linux version 4.20.7-sunxi (root@armbian.com) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019 | ||
22 | console: CPU: ARMv7 Processor [410fc080] revision 0 (ARMv7), cr=50c5387d | ||
23 | console: CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache | ||
24 | console: OF: fdt: Machine model: Cubietech Cubieboard | ||
25 | [...] | ||
26 | console: Boot successful. | ||
27 | console: cat /proc/cpuinfo | ||
28 | console: / # cat /proc/cpuinfo | ||
29 | console: processor : 0 | ||
30 | console: model name : ARMv7 Processor rev 0 (v7l) | ||
31 | console: BogoMIPS : 832.51 | ||
32 | [...] | ||
33 | console: Hardware : Allwinner sun4i/sun5i Families | ||
34 | console: Revision : 0000 | ||
35 | console: Serial : 0000000000000000 | ||
36 | console: cat /proc/iomem | ||
37 | console: / # cat /proc/iomem | ||
38 | console: 01c00000-01c0002f : system-control@1c00000 | ||
39 | console: 01c02000-01c02fff : dma-controller@1c02000 | ||
40 | console: 01c05000-01c05fff : spi@1c05000 | ||
41 | console: 01c0b080-01c0b093 : mdio@1c0b080 | ||
42 | console: 01c0c000-01c0cfff : lcd-controller@1c0c000 | ||
43 | console: 01c0d000-01c0dfff : lcd-controller@1c0d000 | ||
44 | console: 01c0f000-01c0ffff : mmc@1c0f000 | ||
45 | [...] | ||
46 | PASS (54.35 s) | ||
47 | |||
48 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
49 | Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> | ||
50 | Tested-by: Wainer dos Santos Moschetta <wainersm@redhat.com> | ||
51 | Message-id: 20191230110953.25496-2-f4bug@amsat.org | ||
52 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
53 | --- | 7 | --- |
54 | tests/acceptance/boot_linux_console.py | 41 ++++++++++++++++++++++++++ | 8 | hw/arm/realview.c | 33 ++++++++++++++++++++++++--------- |
55 | 1 file changed, 41 insertions(+) | 9 | 1 file changed, 24 insertions(+), 9 deletions(-) |
56 | 10 | ||
57 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 11 | diff --git a/hw/arm/realview.c b/hw/arm/realview.c |
58 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
59 | --- a/tests/acceptance/boot_linux_console.py | 13 | --- a/hw/arm/realview.c |
60 | +++ b/tests/acceptance/boot_linux_console.py | 14 | +++ b/hw/arm/realview.c |
61 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(Test): | 15 | @@ -XXX,XX +XXX,XX @@ |
62 | self.wait_for_console_pattern('Boot successful.') | 16 | #include "hw/sysbus.h" |
63 | # TODO user command, for now the uart is stuck | 17 | #include "hw/arm/boot.h" |
64 | 18 | #include "hw/arm/primecell.h" | |
65 | + def test_arm_cubieboard_initrd(self): | 19 | +#include "hw/core/split-irq.h" |
66 | + """ | 20 | #include "hw/net/lan9118.h" |
67 | + :avocado: tags=arch:arm | 21 | #include "hw/net/smc91c111.h" |
68 | + :avocado: tags=machine:cubieboard | 22 | #include "hw/pci/pci.h" |
69 | + """ | 23 | +#include "hw/qdev-core.h" |
70 | + deb_url = ('https://apt.armbian.com/pool/main/l/' | 24 | #include "net/net.h" |
71 | + 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | 25 | #include "sysemu/sysemu.h" |
72 | + deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | 26 | #include "hw/boards.h" |
73 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | 27 | @@ -XXX,XX +XXX,XX @@ static const int realview_board_id[] = { |
74 | + kernel_path = self.extract_from_deb(deb_path, | 28 | 0x76d |
75 | + '/boot/vmlinuz-4.20.7-sunxi') | 29 | }; |
76 | + dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' | 30 | |
77 | + dtb_path = self.extract_from_deb(deb_path, dtb_path) | 31 | +static void split_irq_from_named(DeviceState *src, const char* outname, |
78 | + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' | 32 | + qemu_irq out1, qemu_irq out2) { |
79 | + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | 33 | + DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ); |
80 | + 'arm/rootfs-armv5.cpio.gz') | ||
81 | + initrd_hash = '2b50f1873e113523967806f4da2afe385462ff9b' | ||
82 | + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) | ||
83 | + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') | ||
84 | + archive.gzip_uncompress(initrd_path_gz, initrd_path) | ||
85 | + | 34 | + |
86 | + self.vm.set_console() | 35 | + qdev_prop_set_uint32(splitter, "num-lines", 2); |
87 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | ||
88 | + 'console=ttyS0,115200 ' | ||
89 | + 'usbcore.nousb ' | ||
90 | + 'panic=-1 noreboot') | ||
91 | + self.vm.add_args('-kernel', kernel_path, | ||
92 | + '-dtb', dtb_path, | ||
93 | + '-initrd', initrd_path, | ||
94 | + '-append', kernel_command_line, | ||
95 | + '-no-reboot') | ||
96 | + self.vm.launch() | ||
97 | + self.wait_for_console_pattern('Boot successful.') | ||
98 | + | 36 | + |
99 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', | 37 | + qdev_realize_and_unref(splitter, NULL, &error_fatal); |
100 | + 'Allwinner sun4i/sun5i') | ||
101 | + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', | ||
102 | + 'system-control@1c00000') | ||
103 | + exec_command_and_wait_for_pattern(self, 'reboot', | ||
104 | + 'reboot: Restarting system') | ||
105 | + | 38 | + |
106 | def test_s390x_s390_ccw_virtio(self): | 39 | + qdev_connect_gpio_out(splitter, 0, out1); |
107 | """ | 40 | + qdev_connect_gpio_out(splitter, 1, out2); |
108 | :avocado: tags=arch:s390x | 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; | ||
109 | -- | 79 | -- |
110 | 2.20.1 | 80 | 2.25.1 |
111 | |||
112 | diff view generated by jsdifflib |
1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | The kernel image and DeviceTree blob are built by the Armbian | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | project (based on Debian): | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | https://docs.armbian.com/Developer-Guide_Build-Preparation/ | 5 | Message-id: 20220324181557.203805-3-zongyuan.li@smartx.com |
6 | |||
7 | The cpio image used comes from the linux-build-test project: | ||
8 | https://github.com/groeck/linux-build-test | ||
9 | |||
10 | If ARM is a target being built, "make check-acceptance" will | ||
11 | automatically include this test by the use of the "arch:arm" tags. | ||
12 | |||
13 | Alternatively, this test can be run using: | ||
14 | |||
15 | $ avocado --show=console run -t machine:cubieboard tests/acceptance/boot_linux_console.py | ||
16 | console: Uncompressing Linux... done, booting the kernel. | ||
17 | console: Booting Linux on physical CPU 0x0 | ||
18 | console: Linux version 4.20.7-sunxi (root@armbian.com) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #5.75 SMP Fri Feb 8 09:02:10 CET 2019 | ||
19 | [...] | ||
20 | console: ahci-sunxi 1c18000.sata: Linked as a consumer to regulator.4 | ||
21 | console: ahci-sunxi 1c18000.sata: controller can't do 64bit DMA, forcing 32bit | ||
22 | console: ahci-sunxi 1c18000.sata: AHCI 0001.0000 32 slots 1 ports 1.5 Gbps 0x1 impl platform mode | ||
23 | console: ahci-sunxi 1c18000.sata: flags: ncq only | ||
24 | console: scsi host0: ahci-sunxi | ||
25 | console: ata1: SATA max UDMA/133 mmio [mem 0x01c18000-0x01c18fff] port 0x100 irq 27 | ||
26 | console: of_cfs_init | ||
27 | console: of_cfs_init: OK | ||
28 | console: vcc3v0: disabling | ||
29 | console: vcc5v0: disabling | ||
30 | console: usb1-vbus: disabling | ||
31 | console: usb2-vbus: disabling | ||
32 | console: ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 300) | ||
33 | console: ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100 | ||
34 | console: ata1.00: 40960 sectors, multi 16: LBA48 NCQ (depth 32) | ||
35 | console: ata1.00: applying bridge limits | ||
36 | console: ata1.00: configured for UDMA/100 | ||
37 | console: scsi 0:0:0:0: Direct-Access ATA QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5 | ||
38 | console: sd 0:0:0:0: Attached scsi generic sg0 type 0 | ||
39 | console: sd 0:0:0:0: [sda] 40960 512-byte logical blocks: (21.0 MB/20.0 MiB) | ||
40 | console: sd 0:0:0:0: [sda] Write Protect is off | ||
41 | console: sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA | ||
42 | console: sd 0:0:0:0: [sda] Attached SCSI disk | ||
43 | console: EXT4-fs (sda): mounting ext2 file system using the ext4 subsystem | ||
44 | console: EXT4-fs (sda): mounted filesystem without journal. Opts: (null) | ||
45 | console: VFS: Mounted root (ext2 filesystem) readonly on device 8:0. | ||
46 | [...] | ||
47 | console: cat /proc/partitions | ||
48 | console: / # cat /proc/partitions | ||
49 | console: major minor #blocks name | ||
50 | console: 1 0 4096 ram0 | ||
51 | console: 1 1 4096 ram1 | ||
52 | console: 1 2 4096 ram2 | ||
53 | console: 1 3 4096 ram3 | ||
54 | console: 8 0 20480 sda | ||
55 | console: reboot | ||
56 | console: / # reboot | ||
57 | [...] | ||
58 | console: sd 0:0:0:0: [sda] Synchronizing SCSI cache | ||
59 | console: reboot: Restarting system | ||
60 | PASS (48.39 s) | ||
61 | |||
62 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
63 | Message-id: 20191230110953.25496-3-f4bug@amsat.org | ||
64 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 6 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
65 | --- | 7 | --- |
66 | tests/acceptance/boot_linux_console.py | 44 ++++++++++++++++++++++++++ | 8 | hw/arm/stellaris.c | 15 +++++++++++++-- |
67 | 1 file changed, 44 insertions(+) | 9 | 1 file changed, 13 insertions(+), 2 deletions(-) |
68 | 10 | ||
69 | diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py | 11 | diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c |
70 | index XXXXXXX..XXXXXXX 100644 | 12 | index XXXXXXX..XXXXXXX 100644 |
71 | --- a/tests/acceptance/boot_linux_console.py | 13 | --- a/hw/arm/stellaris.c |
72 | +++ b/tests/acceptance/boot_linux_console.py | 14 | +++ b/hw/arm/stellaris.c |
73 | @@ -XXX,XX +XXX,XX @@ class BootLinuxConsole(Test): | 15 | @@ -XXX,XX +XXX,XX @@ |
74 | exec_command_and_wait_for_pattern(self, 'reboot', | 16 | |
75 | 'reboot: Restarting system') | 17 | #include "qemu/osdep.h" |
76 | 18 | #include "qapi/error.h" | |
77 | + def test_arm_cubieboard_sata(self): | 19 | +#include "hw/core/split-irq.h" |
78 | + """ | 20 | #include "hw/sysbus.h" |
79 | + :avocado: tags=arch:arm | 21 | #include "hw/sd/sd.h" |
80 | + :avocado: tags=machine:cubieboard | 22 | #include "hw/ssi/ssi.h" |
81 | + """ | 23 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
82 | + deb_url = ('https://apt.armbian.com/pool/main/l/' | 24 | DeviceState *ssddev; |
83 | + 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb') | 25 | DriveInfo *dinfo; |
84 | + deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315' | 26 | DeviceState *carddev; |
85 | + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) | 27 | + DeviceState *gpio_d_splitter; |
86 | + kernel_path = self.extract_from_deb(deb_path, | 28 | BlockBackend *blk; |
87 | + '/boot/vmlinuz-4.20.7-sunxi') | 29 | |
88 | + dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb' | 30 | /* |
89 | + dtb_path = self.extract_from_deb(deb_path, dtb_path) | 31 | @@ -XXX,XX +XXX,XX @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board) |
90 | + rootfs_url = ('https://github.com/groeck/linux-build-test/raw/' | 32 | &error_fatal); |
91 | + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' | 33 | |
92 | + 'arm/rootfs-armv5.ext2.gz') | 34 | ssddev = ssi_create_peripheral(bus, "ssd0323"); |
93 | + rootfs_hash = '093e89d2b4d982234bf528bc9fb2f2f17a9d1f93' | 35 | - gpio_out[GPIO_D][0] = qemu_irq_split( |
94 | + rootfs_path_gz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) | 36 | - qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0), |
95 | + rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') | ||
96 | + archive.gzip_uncompress(rootfs_path_gz, rootfs_path) | ||
97 | + | 37 | + |
98 | + self.vm.set_console() | 38 | + gpio_d_splitter = qdev_new(TYPE_SPLIT_IRQ); |
99 | + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + | 39 | + qdev_prop_set_uint32(gpio_d_splitter, "num-lines", 2); |
100 | + 'console=ttyS0,115200 ' | 40 | + qdev_realize_and_unref(gpio_d_splitter, NULL, &error_fatal); |
101 | + 'usbcore.nousb ' | 41 | + qdev_connect_gpio_out( |
102 | + 'root=/dev/sda ro ' | 42 | + gpio_d_splitter, 0, |
103 | + 'panic=-1 noreboot') | 43 | + qdev_get_gpio_in_named(sddev, SSI_GPIO_CS, 0)); |
104 | + self.vm.add_args('-kernel', kernel_path, | 44 | + qdev_connect_gpio_out( |
105 | + '-dtb', dtb_path, | 45 | + gpio_d_splitter, 1, |
106 | + '-drive', 'if=none,format=raw,id=disk0,file=' | 46 | qdev_get_gpio_in_named(ssddev, SSI_GPIO_CS, 0)); |
107 | + + rootfs_path, | 47 | + gpio_out[GPIO_D][0] = qdev_get_gpio_in(gpio_d_splitter, 0); |
108 | + '-device', 'ide-hd,bus=ide.0,drive=disk0', | ||
109 | + '-append', kernel_command_line, | ||
110 | + '-no-reboot') | ||
111 | + self.vm.launch() | ||
112 | + self.wait_for_console_pattern('Boot successful.') | ||
113 | + | 48 | + |
114 | + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', | 49 | gpio_out[GPIO_C][7] = qdev_get_gpio_in(ssddev, 0); |
115 | + 'Allwinner sun4i/sun5i') | 50 | |
116 | + exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', | 51 | /* Make sure the select pin is high. */ |
117 | + 'sda') | ||
118 | + exec_command_and_wait_for_pattern(self, 'reboot', | ||
119 | + 'reboot: Restarting system') | ||
120 | + | ||
121 | def test_s390x_s390_ccw_virtio(self): | ||
122 | """ | ||
123 | :avocado: tags=arch:s390x | ||
124 | -- | 52 | -- |
125 | 2.20.1 | 53 | 2.25.1 |
126 | |||
127 | diff view generated by jsdifflib |
1 | From: Jeff Kubascik <jeff.kubascik@dornerworks.com> | 1 | From: Zongyuan Li <zongyuan.li@smartx.com> |
---|---|---|---|
2 | 2 | ||
3 | The IAR0/IAR1 register is used to acknowledge an interrupt - a read of the | 3 | Signed-off-by: Zongyuan Li <zongyuan.li@smartx.com> |
4 | register activates the highest priority pending interrupt and provides its | 4 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
5 | interrupt ID. Activating an interrupt can change the CPU's virtual interrupt | 5 | Message-id: 20220324181557.203805-5-zongyuan.li@smartx.com |
6 | state - this change makes sure the virtual irq state is updated. | 6 | Resolves: https://gitlab.com/qemu-project/qemu/-/issues/811 |
7 | |||
8 | Signed-off-by: Jeff Kubascik <jeff.kubascik@dornerworks.com> | ||
9 | Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> | ||
10 | Message-id: 20200113154607.97032-1-jeff.kubascik@dornerworks.com | ||
11 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 7 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
12 | --- | 8 | --- |
13 | hw/intc/arm_gicv3_cpuif.c | 3 +++ | 9 | include/hw/irq.h | 5 ----- |
14 | 1 file changed, 3 insertions(+) | 10 | hw/core/irq.c | 15 --------------- |
11 | 2 files changed, 20 deletions(-) | ||
15 | 12 | ||
16 | diff --git a/hw/intc/arm_gicv3_cpuif.c b/hw/intc/arm_gicv3_cpuif.c | 13 | diff --git a/include/hw/irq.h b/include/hw/irq.h |
17 | index XXXXXXX..XXXXXXX 100644 | 14 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/hw/intc/arm_gicv3_cpuif.c | 15 | --- a/include/hw/irq.h |
19 | +++ b/hw/intc/arm_gicv3_cpuif.c | 16 | +++ b/include/hw/irq.h |
20 | @@ -XXX,XX +XXX,XX @@ static uint64_t icv_iar_read(CPUARMState *env, const ARMCPRegInfo *ri) | 17 | @@ -XXX,XX +XXX,XX @@ void qemu_free_irq(qemu_irq irq); |
21 | 18 | /* Returns a new IRQ with opposite polarity. */ | |
22 | trace_gicv3_icv_iar_read(ri->crm == 8 ? 0 : 1, | 19 | qemu_irq qemu_irq_invert(qemu_irq irq); |
23 | gicv3_redist_affid(cs), intid); | 20 | |
24 | + | 21 | -/* Returns a new IRQ which feeds into both the passed IRQs. |
25 | + gicv3_cpuif_virt_update(cs); | 22 | - * It's probably better to use the TYPE_SPLIT_IRQ device instead. |
26 | + | 23 | - */ |
27 | return intid; | 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); | ||
28 | } | 35 | } |
29 | 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; | ||
30 | -- | 55 | -- |
31 | 2.20.1 | 56 | 2.25.1 |
32 | |||
33 | diff view generated by jsdifflib |
1 | From: Jeff Kubascik <jeff.kubascik@dornerworks.com> | 1 | From: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> |
---|---|---|---|
2 | 2 | ||
3 | The IL bit is set for 32-bit instructions, thus passing false | 3 | Describe that the gic-version influences the maximum number of CPUs. |
4 | with the is_16bit parameter to syn_data_abort_with_iss() makes | ||
5 | a syn mask that always has the IL bit set. | ||
6 | 4 | ||
7 | Pass is_16bit as true to make the initial syn mask have IL=0, | 5 | Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> |
8 | so that the final IL value comes from or'ing template_syn. | 6 | Message-id: 20220413231456.35811-1-heinrich.schuchardt@canonical.com |
9 | 7 | [PMM: minor punctuation tweaks] | |
10 | Cc: qemu-stable@nongnu.org | ||
11 | Fixes: aaa1f954d4ca ("target-arm: A64: Create Instruction Syndromes for Data Aborts") | ||
12 | Signed-off-by: Jeff Kubascik <jeff.kubascik@dornerworks.com> | ||
13 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
14 | Message-id: 20200117004618.2742-2-richard.henderson@linaro.org | ||
15 | [rth: Extracted this as a self-contained bug fix from a larger patch] | ||
16 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
17 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 8 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
18 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
19 | --- | 10 | --- |
20 | target/arm/tlb_helper.c | 2 +- | 11 | docs/system/arm/virt.rst | 4 ++-- |
21 | 1 file changed, 1 insertion(+), 1 deletion(-) | 12 | 1 file changed, 2 insertions(+), 2 deletions(-) |
22 | 13 | ||
23 | diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c | 14 | diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst |
24 | index XXXXXXX..XXXXXXX 100644 | 15 | index XXXXXXX..XXXXXXX 100644 |
25 | --- a/target/arm/tlb_helper.c | 16 | --- a/docs/system/arm/virt.rst |
26 | +++ b/target/arm/tlb_helper.c | 17 | +++ b/docs/system/arm/virt.rst |
27 | @@ -XXX,XX +XXX,XX @@ static inline uint32_t merge_syn_data_abort(uint32_t template_syn, | 18 | @@ -XXX,XX +XXX,XX @@ gic-version |
28 | syn = syn_data_abort_with_iss(same_el, | 19 | Valid values are: |
29 | 0, 0, 0, 0, 0, | 20 | |
30 | ea, 0, s1ptw, is_write, fsc, | 21 | ``2`` |
31 | - false); | 22 | - GICv2 |
32 | + true); | 23 | + GICv2. Note that this limits the number of CPUs to 8. |
33 | /* Merge the runtime syndrome with the template syndrome. */ | 24 | ``3`` |
34 | syn |= template_syn; | 25 | - GICv3 |
35 | } | 26 | + GICv3. This allows up to 512 CPUs. |
27 | ``host`` | ||
28 | Use the same GIC version the host provides, when using KVM | ||
29 | ``max`` | ||
36 | -- | 30 | -- |
37 | 2.20.1 | 31 | 2.25.1 |
38 | |||
39 | diff view generated by jsdifflib |
1 | From: Richard Henderson <richard.henderson@linaro.org> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | During the conversion to decodetree, the setting of | 3 | Similar to the Aspeed code in include/misc/aspeed_scu.h, we define |
4 | ISSIs16Bit got lost. This causes the guest os to | 4 | the PWRON STRAP fields in their corresponding module for NPCM7XX. |
5 | incorrectly adjust trapping memory operations. | ||
6 | 5 | ||
7 | Cc: qemu-stable@nongnu.org | 6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
8 | Fixes: 46beb58efbb8a2a32 ("target/arm: Convert T16, load (literal)") | 7 | Reviewed-by: Patrick Venture <venture@google.com> |
9 | Reported-by: Jeff Kubascik <jeff.kubascik@dornerworks.com> | 8 | Message-id: 20220411165842.3912945-2-wuhaotsh@google.com |
10 | Signed-off-by: Richard Henderson <richard.henderson@linaro.org> | ||
11 | Message-id: 20200117004618.2742-3-richard.henderson@linaro.org | ||
12 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
13 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
14 | --- | 11 | --- |
15 | target/arm/translate.c | 3 +++ | 12 | include/hw/misc/npcm7xx_gcr.h | 30 ++++++++++++++++++++++++++++++ |
16 | 1 file changed, 3 insertions(+) | 13 | 1 file changed, 30 insertions(+) |
17 | 14 | ||
18 | diff --git a/target/arm/translate.c b/target/arm/translate.c | 15 | diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h |
19 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/target/arm/translate.c | 17 | --- a/include/hw/misc/npcm7xx_gcr.h |
21 | +++ b/target/arm/translate.c | 18 | +++ b/include/hw/misc/npcm7xx_gcr.h |
22 | @@ -XXX,XX +XXX,XX @@ static ISSInfo make_issinfo(DisasContext *s, int rd, bool p, bool w) | 19 | @@ -XXX,XX +XXX,XX @@ |
23 | /* ISS not valid if writeback */ | 20 | #include "exec/memory.h" |
24 | if (p && !w) { | 21 | #include "hw/sysbus.h" |
25 | ret = rd; | 22 | |
26 | + if (s->base.pc_next - s->pc_curr == 2) { | 23 | +/* |
27 | + ret |= ISSIs16Bit; | 24 | + * NPCM7XX PWRON STRAP bit fields |
28 | + } | 25 | + * 12: SPI0 powered by VSBV3 at 1.8V |
29 | } else { | 26 | + * 11: System flash attached to BMC |
30 | ret = ISSInvalid; | 27 | + * 10: BSP alternative pins. |
31 | } | 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. | ||
32 | -- | 56 | -- |
33 | 2.20.1 | 57 | 2.25.1 |
34 | |||
35 | diff view generated by jsdifflib |
1 | From: Masahiro Yamada <masahiroy@kernel.org> | 1 | From: Hao Wu <wuhaotsh@google.com> |
---|---|---|---|
2 | 2 | ||
3 | According to the specification "Semihosting for AArch32 and Aarch64", | 3 | This patch uses the defined fields to describe PWRON STRAPs for |
4 | the SYS_OPEN operation should return: | 4 | better readability. |
5 | 5 | ||
6 | - A nonzero handle if the call is successful | 6 | Signed-off-by: Hao Wu <wuhaotsh@google.com> |
7 | - -1 if the call is not successful | 7 | Reviewed-by: Patrick Venture <venture@google.com> |
8 | 8 | Message-id: 20220411165842.3912945-3-wuhaotsh@google.com | |
9 | So, it should never return 0. | 9 | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> |
10 | |||
11 | Prior to commit 35e9a0a8ce4b ("target/arm/arm-semi: Make semihosting | ||
12 | code hand out its own file descriptors"), the guest fd matched to the | ||
13 | host fd. It returned a nonzero handle on success since the fd 0 is | ||
14 | already used for stdin. | ||
15 | |||
16 | Now that the guest fd is the index of guestfd_array, it starts from 0. | ||
17 | |||
18 | I noticed this issue particularly because Trusted Firmware-A built with | ||
19 | PLAT=qemu is no longer working. Its io_semihosting driver only handles | ||
20 | a positive return value as a valid filehandle. | ||
21 | |||
22 | Basically, there are two ways to fix this: | ||
23 | |||
24 | - Use (guestfd - 1) as the index of guestfs_arrary. We need to insert | ||
25 | increment/decrement to convert the guestfd and the array index back | ||
26 | and forth. | ||
27 | |||
28 | - Keep using guestfd as the index of guestfs_array. The first entry | ||
29 | of guestfs_array is left unused. | ||
30 | |||
31 | I thought the latter is simpler. We end up with wasting a small piece | ||
32 | of memory for the unused first entry of guestfd_array, but this is | ||
33 | probably not a big deal. | ||
34 | |||
35 | Fixes: 35e9a0a8ce4b ("target/arm/arm-semi: Make semihosting code hand out its own file descriptors") | ||
36 | Cc: qemu-stable@nongnu.org | ||
37 | Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> | ||
38 | Reviewed-by: Richard Henderson <richard.henderson@linaro.org> | ||
39 | Message-id: 20200109041228.10131-1-masahiroy@kernel.org | ||
40 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> | 10 | Signed-off-by: Peter Maydell <peter.maydell@linaro.org> |
41 | --- | 11 | --- |
42 | target/arm/arm-semi.c | 5 +++-- | 12 | hw/arm/npcm7xx_boards.c | 24 +++++++++++++++++++----- |
43 | 1 file changed, 3 insertions(+), 2 deletions(-) | 13 | 1 file changed, 19 insertions(+), 5 deletions(-) |
44 | 14 | ||
45 | diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c | 15 | diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c |
46 | index XXXXXXX..XXXXXXX 100644 | 16 | index XXXXXXX..XXXXXXX 100644 |
47 | --- a/target/arm/arm-semi.c | 17 | --- a/hw/arm/npcm7xx_boards.c |
48 | +++ b/target/arm/arm-semi.c | 18 | +++ b/hw/arm/npcm7xx_boards.c |
49 | @@ -XXX,XX +XXX,XX @@ static int alloc_guestfd(void) | 19 | @@ -XXX,XX +XXX,XX @@ |
50 | guestfd_array = g_array_new(FALSE, TRUE, sizeof(GuestFD)); | 20 | #include "sysemu/sysemu.h" |
51 | } | 21 | #include "sysemu/block-backend.h" |
52 | 22 | ||
53 | - for (i = 0; i < guestfd_array->len; i++) { | 23 | -#define NPCM750_EVB_POWER_ON_STRAPS 0x00001ff7 |
54 | + /* SYS_OPEN should return nonzero handle on success. Start guestfd from 1 */ | 24 | -#define QUANTA_GSJ_POWER_ON_STRAPS 0x00001fff |
55 | + for (i = 1; i < guestfd_array->len; i++) { | 25 | -#define QUANTA_GBS_POWER_ON_STRAPS 0x000017ff |
56 | GuestFD *gf = &g_array_index(guestfd_array, GuestFD, i); | 26 | -#define KUDO_BMC_POWER_ON_STRAPS 0x00001fff |
57 | 27 | -#define MORI_BMC_POWER_ON_STRAPS 0x00001fff | |
58 | if (gf->type == GuestFDUnused) { | 28 | +#define NPCM7XX_POWER_ON_STRAPS_DEFAULT ( \ |
59 | @@ -XXX,XX +XXX,XX @@ static GuestFD *do_get_guestfd(int guestfd) | 29 | + NPCM7XX_PWRON_STRAP_SPI0F18 | \ |
60 | return NULL; | 30 | + NPCM7XX_PWRON_STRAP_SFAB | \ |
61 | } | 31 | + NPCM7XX_PWRON_STRAP_BSPA | \ |
62 | 32 | + NPCM7XX_PWRON_STRAP_FUP(FUP_NORM_UART2) | \ | |
63 | - if (guestfd < 0 || guestfd >= guestfd_array->len) { | 33 | + NPCM7XX_PWRON_STRAP_SECEN | \ |
64 | + if (guestfd <= 0 || guestfd >= guestfd_array->len) { | 34 | + NPCM7XX_PWRON_STRAP_HIZ | \ |
65 | return NULL; | 35 | + NPCM7XX_PWRON_STRAP_ECC | \ |
66 | } | 36 | + NPCM7XX_PWRON_STRAP_RESERVE1 | \ |
37 | + NPCM7XX_PWRON_STRAP_J2EN | \ | ||
38 | + NPCM7XX_PWRON_STRAP_CKFRQ(CKFRQ_DEFAULT)) | ||
39 | + | ||
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"; | ||
67 | 49 | ||
68 | -- | 50 | -- |
69 | 2.20.1 | 51 | 2.25.1 |
70 | |||
71 | diff view generated by jsdifflib |