1
Some arm patches; my to-review queue is by no means empty, but
1
The following changes since commit 3db29dcac23da85486704ef9e7a8e7217f7829cd:
2
this is a big enough set of patches to be getting on with...
3
2
4
-- PMM
3
Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2023-01-12 13:51:36 +0000)
5
6
The following changes since commit cb9c6a8e5ad6a1f0ce164d352e3102df46986e22:
7
8
.gitlab-ci.d/windows: Work-around timeout and OpenGL problems of the MSYS2 jobs (2023-01-04 18:58:33 +0000)
9
4
10
are available in the Git repository at:
5
are available in the Git repository at:
11
6
12
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230105
7
https://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20230113
13
8
14
for you to fetch changes up to 93c9678de9dc7d2e68f9e8477da072bac30ef132:
9
for you to fetch changes up to 08899b5c68a55a3780d707e2464073c8f2670d31:
15
10
16
hw/net: Fix read of uninitialized memory in imx_fec. (2023-01-05 15:33:00 +0000)
11
target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled (2023-01-13 13:19:36 +0000)
17
12
18
----------------------------------------------------------------
13
----------------------------------------------------------------
19
target-arm queue:
14
target-arm queue:
20
* Implement AArch32 ARMv8-R support
15
hw/arm/stm32f405: correctly describe the memory layout
21
* Add Cortex-R52 CPU
16
hw/arm: Add Olimex H405 board
22
* fix handling of HLT semihosting in system mode
17
cubieboard: Support booting from an SD card image with u-boot on it
23
* hw/timer/ixm_epit: cleanup and fix bug in compare handling
18
target/arm: Fix sve_probe_page
24
* target/arm: Coding style fixes
19
target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
25
* target/arm: Clean up includes
20
various code cleanups
26
* nseries: minor code cleanups
27
* target/arm: align exposed ID registers with Linux
28
* hw/arm/smmu-common: remove unnecessary inlines
29
* i.MX7D: Handle GPT timers
30
* i.MX7D: Connect IRQs to GPIO devices
31
* i.MX6UL: Add a specific GPT timer instance
32
* hw/net: Fix read of uninitialized memory in imx_fec
33
21
34
----------------------------------------------------------------
22
----------------------------------------------------------------
35
Alex Bennée (1):
23
Evgeny Iakovlev (1):
36
target/arm: fix handling of HLT semihosting in system mode
24
target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
37
25
38
Axel Heider (8):
26
Felipe Balbi (2):
39
hw/timer/imx_epit: improve comments
27
hw/arm/stm32f405: correctly describe the memory layout
40
hw/timer/imx_epit: cleanup CR defines
28
hw/arm: Add Olimex H405
41
hw/timer/imx_epit: define SR_OCIF
42
hw/timer/imx_epit: update interrupt state on CR write access
43
hw/timer/imx_epit: hard reset initializes CR with 0
44
hw/timer/imx_epit: factor out register write handlers
45
hw/timer/imx_epit: remove explicit fields cnt and freq
46
hw/timer/imx_epit: fix compare timer handling
47
29
48
Claudio Fontana (1):
30
Philippe Mathieu-Daudé (27):
49
target/arm: cleanup cpu includes
31
hw/arm/pxa2xx: Simplify pxa255_init()
32
hw/arm/pxa2xx: Simplify pxa270_init()
33
hw/arm/collie: Use the IEC binary prefix definitions
34
hw/arm/collie: Simplify flash creation using for() loop
35
hw/arm/gumstix: Improve documentation
36
hw/arm/gumstix: Use the IEC binary prefix definitions
37
hw/arm/mainstone: Use the IEC binary prefix definitions
38
hw/arm/musicpal: Use the IEC binary prefix definitions
39
hw/arm/omap_sx1: Remove unused 'total_ram' definitions
40
hw/arm/omap_sx1: Use the IEC binary prefix definitions
41
hw/arm/z2: Use the IEC binary prefix definitions
42
hw/arm/vexpress: Remove dead code in vexpress_common_init()
43
hw/arm: Remove unreachable code calling pflash_cfi01_register()
44
hw/arm/pxa: Avoid forward-declaring PXA2xxI2CState
45
hw/gpio/omap_gpio: Add local variable to avoid embedded cast
46
hw/arm/omap: Drop useless casts from void * to pointer
47
hw/gpio/omap_gpio: Use CamelCase for TYPE_OMAP1_GPIO type name
48
hw/gpio/omap_gpio: Use CamelCase for TYPE_OMAP2_GPIO type name
49
hw/intc/omap_intc: Use CamelCase for TYPE_OMAP_INTC type name
50
hw/arm/stellaris: Drop useless casts from void * to pointer
51
hw/arm/stellaris: Use CamelCase for STELLARIS_ADC type name
52
hw/arm/bcm2836: Remove definitions generated by OBJECT_DECLARE_TYPE()
53
hw/arm/npcm7xx: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE()
54
hw/misc/sbsa_ec: Rename TYPE_SBSA_EC -> TYPE_SBSA_SECURE_EC
55
hw/misc/sbsa_ec: Declare QOM macros using OBJECT_DECLARE_SIMPLE_TYPE()
56
hw/intc/xilinx_intc: Use 'XpsIntc' typedef instead of 'struct xlx_pic'
57
hw/timer/xilinx_timer: Use XpsTimerState instead of 'struct timerblock'
50
58
51
Fabiano Rosas (5):
59
Richard Henderson (1):
52
target/arm: Fix checkpatch comment style warnings in helper.c
60
target/arm: Fix sve_probe_page
53
target/arm: Fix checkpatch space errors in helper.c
54
target/arm: Fix checkpatch brace errors in helper.c
55
target/arm: Remove unused includes from m_helper.c
56
target/arm: Remove unused includes from helper.c
57
61
58
Jean-Christophe Dubois (4):
62
Strahinja Jankovic (7):
59
i.MX7D: Connect GPT timers to IRQ
63
hw/misc: Allwinner-A10 Clock Controller Module Emulation
60
i.MX7D: Compute clock frequency for the fixed frequency clocks.
64
hw/misc: Allwinner A10 DRAM Controller Emulation
61
i.MX6UL: Add a specific GPT timer instance for the i.MX6UL
65
{hw/i2c,docs/system/arm}: Allwinner TWI/I2C Emulation
62
i.MX7D: Connect IRQs to GPIO devices.
66
hw/misc: AXP209 PMU Emulation
67
hw/arm: Add AXP209 to Cubieboard
68
hw/arm: Allwinner A10 enable SPL load from MMC
69
tests/avocado: Add SD boot test to Cubieboard
63
70
64
Peter Maydell (1):
71
docs/system/arm/cubieboard.rst | 1 +
65
target/arm:Set lg_page_size to 0 if either S1 or S2 asks for it
72
docs/system/arm/orangepi.rst | 1 +
73
docs/system/arm/stm32.rst | 1 +
74
configs/devices/arm-softmmu/default.mak | 1 +
75
include/hw/adc/npcm7xx_adc.h | 7 +-
76
include/hw/arm/allwinner-a10.h | 27 ++
77
include/hw/arm/allwinner-h3.h | 3 +
78
include/hw/arm/npcm7xx.h | 18 +-
79
include/hw/arm/omap.h | 24 +-
80
include/hw/arm/pxa.h | 11 +-
81
include/hw/arm/stm32f405_soc.h | 5 +-
82
include/hw/i2c/allwinner-i2c.h | 55 ++++
83
include/hw/i2c/npcm7xx_smbus.h | 7 +-
84
include/hw/misc/allwinner-a10-ccm.h | 67 +++++
85
include/hw/misc/allwinner-a10-dramc.h | 68 +++++
86
include/hw/misc/npcm7xx_clk.h | 2 +-
87
include/hw/misc/npcm7xx_gcr.h | 6 +-
88
include/hw/misc/npcm7xx_mft.h | 7 +-
89
include/hw/misc/npcm7xx_pwm.h | 3 +-
90
include/hw/misc/npcm7xx_rng.h | 6 +-
91
include/hw/net/npcm7xx_emc.h | 5 +-
92
include/hw/sd/npcm7xx_sdhci.h | 4 +-
93
hw/arm/allwinner-a10.c | 40 +++
94
hw/arm/allwinner-h3.c | 11 +-
95
hw/arm/bcm2836.c | 9 +-
96
hw/arm/collie.c | 25 +-
97
hw/arm/cubieboard.c | 11 +
98
hw/arm/gumstix.c | 45 ++--
99
hw/arm/mainstone.c | 37 ++-
100
hw/arm/musicpal.c | 9 +-
101
hw/arm/olimex-stm32-h405.c | 69 +++++
102
hw/arm/omap1.c | 115 ++++----
103
hw/arm/omap2.c | 40 ++-
104
hw/arm/omap_sx1.c | 53 ++--
105
hw/arm/palm.c | 2 +-
106
hw/arm/pxa2xx.c | 8 +-
107
hw/arm/spitz.c | 6 +-
108
hw/arm/stellaris.c | 73 +++--
109
hw/arm/stm32f405_soc.c | 8 +
110
hw/arm/tosa.c | 2 +-
111
hw/arm/versatilepb.c | 6 +-
112
hw/arm/vexpress.c | 10 +-
113
hw/arm/z2.c | 16 +-
114
hw/char/omap_uart.c | 7 +-
115
hw/display/omap_dss.c | 15 +-
116
hw/display/omap_lcdc.c | 9 +-
117
hw/dma/omap_dma.c | 15 +-
118
hw/gpio/omap_gpio.c | 48 ++--
119
hw/i2c/allwinner-i2c.c | 459 ++++++++++++++++++++++++++++++++
120
hw/intc/omap_intc.c | 38 +--
121
hw/intc/xilinx_intc.c | 28 +-
122
hw/misc/allwinner-a10-ccm.c | 224 ++++++++++++++++
123
hw/misc/allwinner-a10-dramc.c | 179 +++++++++++++
124
hw/misc/axp209.c | 238 +++++++++++++++++
125
hw/misc/omap_gpmc.c | 12 +-
126
hw/misc/omap_l4.c | 7 +-
127
hw/misc/omap_sdrc.c | 7 +-
128
hw/misc/omap_tap.c | 5 +-
129
hw/misc/sbsa_ec.c | 12 +-
130
hw/sd/omap_mmc.c | 9 +-
131
hw/ssi/omap_spi.c | 7 +-
132
hw/timer/omap_gptimer.c | 22 +-
133
hw/timer/omap_synctimer.c | 4 +-
134
hw/timer/xilinx_timer.c | 27 +-
135
target/arm/helper.c | 3 +
136
target/arm/sve_helper.c | 14 +-
137
MAINTAINERS | 8 +
138
hw/arm/Kconfig | 9 +
139
hw/arm/meson.build | 1 +
140
hw/i2c/Kconfig | 4 +
141
hw/i2c/meson.build | 1 +
142
hw/i2c/trace-events | 5 +
143
hw/misc/Kconfig | 10 +
144
hw/misc/meson.build | 3 +
145
hw/misc/trace-events | 5 +
146
tests/avocado/boot_linux_console.py | 47 ++++
147
76 files changed, 1951 insertions(+), 455 deletions(-)
148
create mode 100644 include/hw/i2c/allwinner-i2c.h
149
create mode 100644 include/hw/misc/allwinner-a10-ccm.h
150
create mode 100644 include/hw/misc/allwinner-a10-dramc.h
151
create mode 100644 hw/arm/olimex-stm32-h405.c
152
create mode 100644 hw/i2c/allwinner-i2c.c
153
create mode 100644 hw/misc/allwinner-a10-ccm.c
154
create mode 100644 hw/misc/allwinner-a10-dramc.c
155
create mode 100644 hw/misc/axp209.c
66
156
67
Philippe Mathieu-Daudé (5):
68
hw/input/tsc2xxx: Constify set_transform()'s MouseTransformInfo arg
69
hw/arm/nseries: Constify various read-only arrays
70
hw/arm/nseries: Silent -Wmissing-field-initializers warning
71
hw/arm/smmu-common: Reduce smmu_inv_notifiers_mr() scope
72
hw/arm/smmu-common: Avoid using inlined functions with external linkage
73
74
Stephen Longfield (1):
75
hw/net: Fix read of uninitialized memory in imx_fec.
76
77
Tobias Röhmel (7):
78
target/arm: Don't add all MIDR aliases for cores that implement PMSA
79
target/arm: Make RVBAR available for all ARMv8 CPUs
80
target/arm: Make stage_2_format for cache attributes optional
81
target/arm: Enable TTBCR_EAE for ARMv8-R AArch32
82
target/arm: Add PMSAv8r registers
83
target/arm: Add PMSAv8r functionality
84
target/arm: Add ARM Cortex-R52 CPU
85
86
Zhuojia Shen (1):
87
target/arm: align exposed ID registers with Linux
88
89
include/hw/arm/fsl-imx7.h | 20 +
90
include/hw/arm/smmu-common.h | 3 -
91
include/hw/input/tsc2xxx.h | 4 +-
92
include/hw/timer/imx_epit.h | 8 +-
93
include/hw/timer/imx_gpt.h | 1 +
94
target/arm/cpu.h | 6 +
95
target/arm/internals.h | 4 +
96
hw/arm/fsl-imx6ul.c | 2 +-
97
hw/arm/fsl-imx7.c | 41 +-
98
hw/arm/nseries.c | 28 +-
99
hw/arm/smmu-common.c | 15 +-
100
hw/input/tsc2005.c | 2 +-
101
hw/input/tsc210x.c | 3 +-
102
hw/misc/imx6ul_ccm.c | 6 -
103
hw/misc/imx7_ccm.c | 49 ++-
104
hw/net/imx_fec.c | 8 +-
105
hw/timer/imx_epit.c | 376 +++++++++-------
106
hw/timer/imx_gpt.c | 25 ++
107
target/arm/cpu.c | 35 +-
108
target/arm/cpu64.c | 6 -
109
target/arm/cpu_tcg.c | 42 ++
110
target/arm/debug_helper.c | 3 +
111
target/arm/helper.c | 871 +++++++++++++++++++++++++++++---------
112
target/arm/m_helper.c | 16 -
113
target/arm/machine.c | 28 ++
114
target/arm/ptw.c | 152 +++++--
115
target/arm/tlb_helper.c | 4 +
116
target/arm/translate.c | 2 +-
117
tests/tcg/aarch64/sysregs.c | 24 +-
118
tests/tcg/aarch64/Makefile.target | 7 +-
119
30 files changed, 1330 insertions(+), 461 deletions(-)
120
diff view generated by jsdifflib
1
From: Zhuojia Shen <chaosdefinition@hotmail.com>
1
From: Felipe Balbi <balbi@kernel.org>
2
2
3
In CPUID registers exposed to userspace, some registers were missing
3
STM32F405 has 128K of SRAM and another 64K of CCM (Core-coupled
4
and some fields were not exposed. This patch aligns exposed ID
4
Memory) at a different base address. Correctly describe the memory
5
registers and their fields with what the upstream kernel currently
5
layout to give existing FW images a chance to run unmodified.
6
exposes.
7
6
8
Specifically, the following new ID registers/fields are exposed to
7
Reviewed-by: Alistair Francis <alistair@alistair23.me>
9
userspace:
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
9
Signed-off-by: Felipe Balbi <balbi@kernel.org>
11
ID_AA64PFR1_EL1.BT: bits 3-0
10
Message-id: 20221230145733.200496-2-balbi@kernel.org
12
ID_AA64PFR1_EL1.MTE: bits 11-8
13
ID_AA64PFR1_EL1.SME: bits 27-24
14
15
ID_AA64ZFR0_EL1.SVEver: bits 3-0
16
ID_AA64ZFR0_EL1.AES: bits 7-4
17
ID_AA64ZFR0_EL1.BitPerm: bits 19-16
18
ID_AA64ZFR0_EL1.BF16: bits 23-20
19
ID_AA64ZFR0_EL1.SHA3: bits 35-32
20
ID_AA64ZFR0_EL1.SM4: bits 43-40
21
ID_AA64ZFR0_EL1.I8MM: bits 47-44
22
ID_AA64ZFR0_EL1.F32MM: bits 55-52
23
ID_AA64ZFR0_EL1.F64MM: bits 59-56
24
25
ID_AA64SMFR0_EL1.F32F32: bit 32
26
ID_AA64SMFR0_EL1.B16F32: bit 34
27
ID_AA64SMFR0_EL1.F16F32: bit 35
28
ID_AA64SMFR0_EL1.I8I32: bits 39-36
29
ID_AA64SMFR0_EL1.F64F64: bit 48
30
ID_AA64SMFR0_EL1.I16I64: bits 55-52
31
ID_AA64SMFR0_EL1.FA64: bit 63
32
33
ID_AA64MMFR0_EL1.ECV: bits 63-60
34
35
ID_AA64MMFR1_EL1.AFP: bits 47-44
36
37
ID_AA64MMFR2_EL1.AT: bits 35-32
38
39
ID_AA64ISAR0_EL1.RNDR: bits 63-60
40
41
ID_AA64ISAR1_EL1.FRINTTS: bits 35-32
42
ID_AA64ISAR1_EL1.BF16: bits 47-44
43
ID_AA64ISAR1_EL1.DGH: bits 51-48
44
ID_AA64ISAR1_EL1.I8MM: bits 55-52
45
46
ID_AA64ISAR2_EL1.WFxT: bits 3-0
47
ID_AA64ISAR2_EL1.RPRES: bits 7-4
48
ID_AA64ISAR2_EL1.GPA3: bits 11-8
49
ID_AA64ISAR2_EL1.APA3: bits 15-12
50
51
The code is also refactored to use symbolic names for ID register fields
52
for better readability and maintainability.
53
54
The test case in tests/tcg/aarch64/sysregs.c is also updated to match
55
the intended behavior.
56
57
Signed-off-by: Zhuojia Shen <chaosdefinition@hotmail.com>
58
Message-id: DS7PR12MB6309FB585E10772928F14271ACE79@DS7PR12MB6309.namprd12.prod.outlook.com
59
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
60
[PMM: use Sn_n_Cn_Cn_n syntax to work with older assemblers
61
that don't recognize id_aa64isar2_el1 and id_aa64mmfr2_el1]
62
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
63
---
12
---
64
target/arm/helper.c | 96 +++++++++++++++++++++++++------
13
include/hw/arm/stm32f405_soc.h | 5 ++++-
65
tests/tcg/aarch64/sysregs.c | 24 ++++++--
14
hw/arm/stm32f405_soc.c | 8 ++++++++
66
tests/tcg/aarch64/Makefile.target | 7 ++-
15
2 files changed, 12 insertions(+), 1 deletion(-)
67
3 files changed, 103 insertions(+), 24 deletions(-)
68
16
69
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
diff --git a/include/hw/arm/stm32f405_soc.h b/include/hw/arm/stm32f405_soc.h
70
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
71
--- a/target/arm/helper.c
19
--- a/include/hw/arm/stm32f405_soc.h
72
+++ b/target/arm/helper.c
20
+++ b/include/hw/arm/stm32f405_soc.h
73
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
21
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F405State, STM32F405_SOC)
74
#ifdef CONFIG_USER_ONLY
22
#define FLASH_BASE_ADDRESS 0x08000000
75
static const ARMCPRegUserSpaceInfo v8_user_idregs[] = {
23
#define FLASH_SIZE (1024 * 1024)
76
{ .name = "ID_AA64PFR0_EL1",
24
#define SRAM_BASE_ADDRESS 0x20000000
77
- .exported_bits = 0x000f000f00ff0000,
25
-#define SRAM_SIZE (192 * 1024)
78
- .fixed_bits = 0x0000000000000011 },
26
+#define SRAM_SIZE (128 * 1024)
79
+ .exported_bits = R_ID_AA64PFR0_FP_MASK |
27
+#define CCM_BASE_ADDRESS 0x10000000
80
+ R_ID_AA64PFR0_ADVSIMD_MASK |
28
+#define CCM_SIZE (64 * 1024)
81
+ R_ID_AA64PFR0_SVE_MASK |
29
82
+ R_ID_AA64PFR0_DIT_MASK,
30
struct STM32F405State {
83
+ .fixed_bits = (0x1u << R_ID_AA64PFR0_EL0_SHIFT) |
31
/*< private >*/
84
+ (0x1u << R_ID_AA64PFR0_EL1_SHIFT) },
32
@@ -XXX,XX +XXX,XX @@ struct STM32F405State {
85
{ .name = "ID_AA64PFR1_EL1",
33
STM32F2XXADCState adc[STM_NUM_ADCS];
86
- .exported_bits = 0x00000000000000f0 },
34
STM32F2XXSPIState spi[STM_NUM_SPIS];
87
+ .exported_bits = R_ID_AA64PFR1_BT_MASK |
35
88
+ R_ID_AA64PFR1_SSBS_MASK |
36
+ MemoryRegion ccm;
89
+ R_ID_AA64PFR1_MTE_MASK |
37
MemoryRegion sram;
90
+ R_ID_AA64PFR1_SME_MASK },
38
MemoryRegion flash;
91
{ .name = "ID_AA64PFR*_EL1_RESERVED",
39
MemoryRegion flash_alias;
92
- .is_glob = true },
40
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
93
- { .name = "ID_AA64ZFR0_EL1" },
94
+ .is_glob = true },
95
+ { .name = "ID_AA64ZFR0_EL1",
96
+ .exported_bits = R_ID_AA64ZFR0_SVEVER_MASK |
97
+ R_ID_AA64ZFR0_AES_MASK |
98
+ R_ID_AA64ZFR0_BITPERM_MASK |
99
+ R_ID_AA64ZFR0_BFLOAT16_MASK |
100
+ R_ID_AA64ZFR0_SHA3_MASK |
101
+ R_ID_AA64ZFR0_SM4_MASK |
102
+ R_ID_AA64ZFR0_I8MM_MASK |
103
+ R_ID_AA64ZFR0_F32MM_MASK |
104
+ R_ID_AA64ZFR0_F64MM_MASK },
105
+ { .name = "ID_AA64SMFR0_EL1",
106
+ .exported_bits = R_ID_AA64SMFR0_F32F32_MASK |
107
+ R_ID_AA64SMFR0_B16F32_MASK |
108
+ R_ID_AA64SMFR0_F16F32_MASK |
109
+ R_ID_AA64SMFR0_I8I32_MASK |
110
+ R_ID_AA64SMFR0_F64F64_MASK |
111
+ R_ID_AA64SMFR0_I16I64_MASK |
112
+ R_ID_AA64SMFR0_FA64_MASK },
113
{ .name = "ID_AA64MMFR0_EL1",
114
- .fixed_bits = 0x00000000ff000000 },
115
- { .name = "ID_AA64MMFR1_EL1" },
116
+ .exported_bits = R_ID_AA64MMFR0_ECV_MASK,
117
+ .fixed_bits = (0xfu << R_ID_AA64MMFR0_TGRAN64_SHIFT) |
118
+ (0xfu << R_ID_AA64MMFR0_TGRAN4_SHIFT) },
119
+ { .name = "ID_AA64MMFR1_EL1",
120
+ .exported_bits = R_ID_AA64MMFR1_AFP_MASK },
121
+ { .name = "ID_AA64MMFR2_EL1",
122
+ .exported_bits = R_ID_AA64MMFR2_AT_MASK },
123
{ .name = "ID_AA64MMFR*_EL1_RESERVED",
124
- .is_glob = true },
125
+ .is_glob = true },
126
{ .name = "ID_AA64DFR0_EL1",
127
- .fixed_bits = 0x0000000000000006 },
128
- { .name = "ID_AA64DFR1_EL1" },
129
+ .fixed_bits = (0x6u << R_ID_AA64DFR0_DEBUGVER_SHIFT) },
130
+ { .name = "ID_AA64DFR1_EL1" },
131
{ .name = "ID_AA64DFR*_EL1_RESERVED",
132
- .is_glob = true },
133
+ .is_glob = true },
134
{ .name = "ID_AA64AFR*",
135
- .is_glob = true },
136
+ .is_glob = true },
137
{ .name = "ID_AA64ISAR0_EL1",
138
- .exported_bits = 0x00fffffff0fffff0 },
139
+ .exported_bits = R_ID_AA64ISAR0_AES_MASK |
140
+ R_ID_AA64ISAR0_SHA1_MASK |
141
+ R_ID_AA64ISAR0_SHA2_MASK |
142
+ R_ID_AA64ISAR0_CRC32_MASK |
143
+ R_ID_AA64ISAR0_ATOMIC_MASK |
144
+ R_ID_AA64ISAR0_RDM_MASK |
145
+ R_ID_AA64ISAR0_SHA3_MASK |
146
+ R_ID_AA64ISAR0_SM3_MASK |
147
+ R_ID_AA64ISAR0_SM4_MASK |
148
+ R_ID_AA64ISAR0_DP_MASK |
149
+ R_ID_AA64ISAR0_FHM_MASK |
150
+ R_ID_AA64ISAR0_TS_MASK |
151
+ R_ID_AA64ISAR0_RNDR_MASK },
152
{ .name = "ID_AA64ISAR1_EL1",
153
- .exported_bits = 0x000000f0ffffffff },
154
+ .exported_bits = R_ID_AA64ISAR1_DPB_MASK |
155
+ R_ID_AA64ISAR1_APA_MASK |
156
+ R_ID_AA64ISAR1_API_MASK |
157
+ R_ID_AA64ISAR1_JSCVT_MASK |
158
+ R_ID_AA64ISAR1_FCMA_MASK |
159
+ R_ID_AA64ISAR1_LRCPC_MASK |
160
+ R_ID_AA64ISAR1_GPA_MASK |
161
+ R_ID_AA64ISAR1_GPI_MASK |
162
+ R_ID_AA64ISAR1_FRINTTS_MASK |
163
+ R_ID_AA64ISAR1_SB_MASK |
164
+ R_ID_AA64ISAR1_BF16_MASK |
165
+ R_ID_AA64ISAR1_DGH_MASK |
166
+ R_ID_AA64ISAR1_I8MM_MASK },
167
+ { .name = "ID_AA64ISAR2_EL1",
168
+ .exported_bits = R_ID_AA64ISAR2_WFXT_MASK |
169
+ R_ID_AA64ISAR2_RPRES_MASK |
170
+ R_ID_AA64ISAR2_GPA3_MASK |
171
+ R_ID_AA64ISAR2_APA3_MASK },
172
{ .name = "ID_AA64ISAR*_EL1_RESERVED",
173
- .is_glob = true },
174
+ .is_glob = true },
175
};
176
modify_arm_cp_regs(v8_idregs, v8_user_idregs);
177
#endif
178
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
179
#ifdef CONFIG_USER_ONLY
180
static const ARMCPRegUserSpaceInfo id_v8_user_midr_cp_reginfo[] = {
181
{ .name = "MIDR_EL1",
182
- .exported_bits = 0x00000000ffffffff },
183
- { .name = "REVIDR_EL1" },
184
+ .exported_bits = R_MIDR_EL1_REVISION_MASK |
185
+ R_MIDR_EL1_PARTNUM_MASK |
186
+ R_MIDR_EL1_ARCHITECTURE_MASK |
187
+ R_MIDR_EL1_VARIANT_MASK |
188
+ R_MIDR_EL1_IMPLEMENTER_MASK },
189
+ { .name = "REVIDR_EL1" },
190
};
191
modify_arm_cp_regs(id_v8_midr_cp_reginfo, id_v8_user_midr_cp_reginfo);
192
#endif
193
diff --git a/tests/tcg/aarch64/sysregs.c b/tests/tcg/aarch64/sysregs.c
194
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
195
--- a/tests/tcg/aarch64/sysregs.c
42
--- a/hw/arm/stm32f405_soc.c
196
+++ b/tests/tcg/aarch64/sysregs.c
43
+++ b/hw/arm/stm32f405_soc.c
197
@@ -XXX,XX +XXX,XX @@
44
@@ -XXX,XX +XXX,XX @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
198
#define HWCAP_CPUID (1 << 11)
45
}
199
#endif
46
memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram);
200
47
201
+/*
48
+ memory_region_init_ram(&s->ccm, NULL, "STM32F405.ccm", CCM_SIZE,
202
+ * Older assemblers don't recognize newer system register names,
49
+ &err);
203
+ * but we can still access them by the Sn_n_Cn_Cn_n syntax.
50
+ if (err != NULL) {
204
+ */
51
+ error_propagate(errp, err);
205
+#define SYS_ID_AA64ISAR2_EL1 S3_0_C0_C6_2
52
+ return;
206
+#define SYS_ID_AA64MMFR2_EL1 S3_0_C0_C7_2
53
+ }
54
+ memory_region_add_subregion(system_memory, CCM_BASE_ADDRESS, &s->ccm);
207
+
55
+
208
int failed_bit_count;
56
armv7m = DEVICE(&s->armv7m);
209
57
qdev_prop_set_uint32(armv7m, "num-irq", 96);
210
/* Read and print system register `id' value */
58
qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
211
@@ -XXX,XX +XXX,XX @@ int main(void)
212
* minimum valid fields - for the purposes of this check allowed
213
* to have non-zero values.
214
*/
215
- get_cpu_reg_check_mask(id_aa64isar0_el1, _m(00ff,ffff,f0ff,fff0));
216
- get_cpu_reg_check_mask(id_aa64isar1_el1, _m(0000,00f0,ffff,ffff));
217
+ get_cpu_reg_check_mask(id_aa64isar0_el1, _m(f0ff,ffff,f0ff,fff0));
218
+ get_cpu_reg_check_mask(id_aa64isar1_el1, _m(00ff,f0ff,ffff,ffff));
219
+ get_cpu_reg_check_mask(SYS_ID_AA64ISAR2_EL1, _m(0000,0000,0000,ffff));
220
/* TGran4 & TGran64 as pegged to -1 */
221
- get_cpu_reg_check_mask(id_aa64mmfr0_el1, _m(0000,0000,ff00,0000));
222
- get_cpu_reg_check_zero(id_aa64mmfr1_el1);
223
+ get_cpu_reg_check_mask(id_aa64mmfr0_el1, _m(f000,0000,ff00,0000));
224
+ get_cpu_reg_check_mask(id_aa64mmfr1_el1, _m(0000,f000,0000,0000));
225
+ get_cpu_reg_check_mask(SYS_ID_AA64MMFR2_EL1, _m(0000,000f,0000,0000));
226
/* EL1/EL0 reported as AA64 only */
227
get_cpu_reg_check_mask(id_aa64pfr0_el1, _m(000f,000f,00ff,0011));
228
- get_cpu_reg_check_mask(id_aa64pfr1_el1, _m(0000,0000,0000,00f0));
229
+ get_cpu_reg_check_mask(id_aa64pfr1_el1, _m(0000,0000,0f00,0fff));
230
/* all hidden, DebugVer fixed to 0x6 (ARMv8 debug architecture) */
231
get_cpu_reg_check_mask(id_aa64dfr0_el1, _m(0000,0000,0000,0006));
232
get_cpu_reg_check_zero(id_aa64dfr1_el1);
233
- get_cpu_reg_check_zero(id_aa64zfr0_el1);
234
+ get_cpu_reg_check_mask(id_aa64zfr0_el1, _m(0ff0,ff0f,00ff,00ff));
235
+#ifdef HAS_ARMV9_SME
236
+ get_cpu_reg_check_mask(id_aa64smfr0_el1, _m(80f1,00fd,0000,0000));
237
+#endif
238
239
get_cpu_reg_check_zero(id_aa64afr0_el1);
240
get_cpu_reg_check_zero(id_aa64afr1_el1);
241
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
242
index XXXXXXX..XXXXXXX 100644
243
--- a/tests/tcg/aarch64/Makefile.target
244
+++ b/tests/tcg/aarch64/Makefile.target
245
@@ -XXX,XX +XXX,XX @@ config-cc.mak: Makefile
246
     $(call cc-option,-march=armv8.1-a+sve2, CROSS_CC_HAS_SVE2); \
247
     $(call cc-option,-march=armv8.3-a, CROSS_CC_HAS_ARMV8_3); \
248
     $(call cc-option,-mbranch-protection=standard, CROSS_CC_HAS_ARMV8_BTI); \
249
-     $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE)) 3> config-cc.mak
250
+     $(call cc-option,-march=armv8.5-a+memtag, CROSS_CC_HAS_ARMV8_MTE); \
251
+     $(call cc-option,-march=armv9-a+sme, CROSS_CC_HAS_ARMV9_SME)) 3> config-cc.mak
252
-include config-cc.mak
253
254
# Pauth Tests
255
@@ -XXX,XX +XXX,XX @@ endif
256
ifneq ($(CROSS_CC_HAS_SVE),)
257
# System Registers Tests
258
AARCH64_TESTS += sysregs
259
+ifneq ($(CROSS_CC_HAS_ARMV9_SME),)
260
+sysregs: CFLAGS+=-march=armv9-a+sme -DHAS_ARMV9_SME
261
+else
262
sysregs: CFLAGS+=-march=armv8.1-a+sve
263
+endif
264
265
# SVE ioctl test
266
AARCH64_TESTS += sve-ioctls
267
--
59
--
268
2.25.1
60
2.34.1
61
62
diff view generated by jsdifflib
1
From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
1
From: Felipe Balbi <balbi@kernel.org>
2
2
3
All constants are taken from the ARM Cortex-R52 Processor TRM Revision: r1p3
3
Olimex makes a series of low-cost STM32 boards. This commit introduces
4
the minimum setup to support SMT32-H405. See [1] for details
4
5
5
Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
6
[1] https://www.olimex.com/Products/ARM/ST/STM32-H405/
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
7
Message-id: 20221206102504.165775-8-tobias.roehmel@rwth-aachen.de
8
Signed-off-by: Felipe Balbi <balbi@kernel.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Message-id: 20221230145733.200496-3-balbi@kernel.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
13
---
10
target/arm/cpu_tcg.c | 42 ++++++++++++++++++++++++++++++++++++++++++
14
docs/system/arm/stm32.rst | 1 +
11
1 file changed, 42 insertions(+)
15
configs/devices/arm-softmmu/default.mak | 1 +
16
hw/arm/olimex-stm32-h405.c | 69 +++++++++++++++++++++++++
17
MAINTAINERS | 6 +++
18
hw/arm/Kconfig | 4 ++
19
hw/arm/meson.build | 1 +
20
6 files changed, 82 insertions(+)
21
create mode 100644 hw/arm/olimex-stm32-h405.c
12
22
13
diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c
23
diff --git a/docs/system/arm/stm32.rst b/docs/system/arm/stm32.rst
14
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu_tcg.c
25
--- a/docs/system/arm/stm32.rst
16
+++ b/target/arm/cpu_tcg.c
26
+++ b/docs/system/arm/stm32.rst
17
@@ -XXX,XX +XXX,XX @@ static void cortex_r5_initfn(Object *obj)
27
@@ -XXX,XX +XXX,XX @@ The STM32F4 series is based on ARM Cortex-M4F core. This series is pin-to-pin
18
define_arm_cp_regs(cpu, cortexr5_cp_reginfo);
28
compatible with STM32F2 series. The following machines are based on this chip :
19
}
29
20
30
- ``netduinoplus2`` Netduino Plus 2 board with STM32F405RGT6 microcontroller
21
+static void cortex_r52_initfn(Object *obj)
31
+- ``olimex-stm32-h405`` Olimex STM32 H405 board with STM32F405RGT6 microcontroller
32
33
There are many other STM32 series that are currently not supported by QEMU.
34
35
diff --git a/configs/devices/arm-softmmu/default.mak b/configs/devices/arm-softmmu/default.mak
36
index XXXXXXX..XXXXXXX 100644
37
--- a/configs/devices/arm-softmmu/default.mak
38
+++ b/configs/devices/arm-softmmu/default.mak
39
@@ -XXX,XX +XXX,XX @@ CONFIG_COLLIE=y
40
CONFIG_ASPEED_SOC=y
41
CONFIG_NETDUINO2=y
42
CONFIG_NETDUINOPLUS2=y
43
+CONFIG_OLIMEX_STM32_H405=y
44
CONFIG_MPS2=y
45
CONFIG_RASPI=y
46
CONFIG_DIGIC=y
47
diff --git a/hw/arm/olimex-stm32-h405.c b/hw/arm/olimex-stm32-h405.c
48
new file mode 100644
49
index XXXXXXX..XXXXXXX
50
--- /dev/null
51
+++ b/hw/arm/olimex-stm32-h405.c
52
@@ -XXX,XX +XXX,XX @@
53
+/*
54
+ * ST STM32VLDISCOVERY machine
55
+ * Olimex STM32-H405 machine
56
+ *
57
+ * Copyright (c) 2022 Felipe Balbi <balbi@kernel.org>
58
+ *
59
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
60
+ * of this software and associated documentation files (the "Software"), to deal
61
+ * in the Software without restriction, including without limitation the rights
62
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
63
+ * copies of the Software, and to permit persons to whom the Software is
64
+ * furnished to do so, subject to the following conditions:
65
+ *
66
+ * The above copyright notice and this permission notice shall be included in
67
+ * all copies or substantial portions of the Software.
68
+ *
69
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
72
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
75
+ * THE SOFTWARE.
76
+ */
77
+
78
+#include "qemu/osdep.h"
79
+#include "qapi/error.h"
80
+#include "hw/boards.h"
81
+#include "hw/qdev-properties.h"
82
+#include "hw/qdev-clock.h"
83
+#include "qemu/error-report.h"
84
+#include "hw/arm/stm32f405_soc.h"
85
+#include "hw/arm/boot.h"
86
+
87
+/* olimex-stm32-h405 implementation is derived from netduinoplus2 */
88
+
89
+/* Main SYSCLK frequency in Hz (168MHz) */
90
+#define SYSCLK_FRQ 168000000ULL
91
+
92
+static void olimex_stm32_h405_init(MachineState *machine)
22
+{
93
+{
23
+ ARMCPU *cpu = ARM_CPU(obj);
94
+ DeviceState *dev;
95
+ Clock *sysclk;
24
+
96
+
25
+ set_feature(&cpu->env, ARM_FEATURE_V8);
97
+ /* This clock doesn't need migration because it is fixed-frequency */
26
+ set_feature(&cpu->env, ARM_FEATURE_EL2);
98
+ sysclk = clock_new(OBJECT(machine), "SYSCLK");
27
+ set_feature(&cpu->env, ARM_FEATURE_PMSA);
99
+ clock_set_hz(sysclk, SYSCLK_FRQ);
28
+ set_feature(&cpu->env, ARM_FEATURE_NEON);
29
+ set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
30
+ cpu->midr = 0x411fd133; /* r1p3 */
31
+ cpu->revidr = 0x00000000;
32
+ cpu->reset_fpsid = 0x41034023;
33
+ cpu->isar.mvfr0 = 0x10110222;
34
+ cpu->isar.mvfr1 = 0x12111111;
35
+ cpu->isar.mvfr2 = 0x00000043;
36
+ cpu->ctr = 0x8144c004;
37
+ cpu->reset_sctlr = 0x30c50838;
38
+ cpu->isar.id_pfr0 = 0x00000131;
39
+ cpu->isar.id_pfr1 = 0x10111001;
40
+ cpu->isar.id_dfr0 = 0x03010006;
41
+ cpu->id_afr0 = 0x00000000;
42
+ cpu->isar.id_mmfr0 = 0x00211040;
43
+ cpu->isar.id_mmfr1 = 0x40000000;
44
+ cpu->isar.id_mmfr2 = 0x01200000;
45
+ cpu->isar.id_mmfr3 = 0xf0102211;
46
+ cpu->isar.id_mmfr4 = 0x00000010;
47
+ cpu->isar.id_isar0 = 0x02101110;
48
+ cpu->isar.id_isar1 = 0x13112111;
49
+ cpu->isar.id_isar2 = 0x21232142;
50
+ cpu->isar.id_isar3 = 0x01112131;
51
+ cpu->isar.id_isar4 = 0x00010142;
52
+ cpu->isar.id_isar5 = 0x00010001;
53
+ cpu->isar.dbgdidr = 0x77168000;
54
+ cpu->clidr = (1 << 27) | (1 << 24) | 0x3;
55
+ cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */
56
+ cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */
57
+
100
+
58
+ cpu->pmsav7_dregion = 16;
101
+ dev = qdev_new(TYPE_STM32F405_SOC);
59
+ cpu->pmsav8r_hdregion = 16;
102
+ qdev_prop_set_string(dev, "cpu-type", ARM_CPU_TYPE_NAME("cortex-m4"));
103
+ qdev_connect_clock_in(dev, "sysclk", sysclk);
104
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
105
+
106
+ armv7m_load_kernel(ARM_CPU(first_cpu),
107
+ machine->kernel_filename,
108
+ 0, FLASH_SIZE);
60
+}
109
+}
61
+
110
+
62
static void cortex_r5f_initfn(Object *obj)
111
+static void olimex_stm32_h405_machine_init(MachineClass *mc)
63
{
112
+{
64
ARMCPU *cpu = ARM_CPU(obj);
113
+ mc->desc = "Olimex STM32-H405 (Cortex-M4)";
65
@@ -XXX,XX +XXX,XX @@ static const ARMCPUInfo arm_tcg_cpus[] = {
114
+ mc->init = olimex_stm32_h405_init;
66
.class_init = arm_v7m_class_init },
115
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m4");
67
{ .name = "cortex-r5", .initfn = cortex_r5_initfn },
116
+
68
{ .name = "cortex-r5f", .initfn = cortex_r5f_initfn },
117
+ /* SRAM pre-allocated as part of the SoC instantiation */
69
+ { .name = "cortex-r52", .initfn = cortex_r52_initfn },
118
+ mc->default_ram_size = 0;
70
{ .name = "ti925t", .initfn = ti925t_initfn },
119
+}
71
{ .name = "sa1100", .initfn = sa1100_initfn },
120
+
72
{ .name = "sa1110", .initfn = sa1110_initfn },
121
+DEFINE_MACHINE("olimex-stm32-h405", olimex_stm32_h405_machine_init)
122
diff --git a/MAINTAINERS b/MAINTAINERS
123
index XXXXXXX..XXXXXXX 100644
124
--- a/MAINTAINERS
125
+++ b/MAINTAINERS
126
@@ -XXX,XX +XXX,XX @@ L: qemu-arm@nongnu.org
127
S: Maintained
128
F: hw/arm/netduinoplus2.c
129
130
+Olimex STM32 H405
131
+M: Felipe Balbi <balbi@kernel.org>
132
+L: qemu-arm@nongnu.org
133
+S: Maintained
134
+F: hw/arm/olimex-stm32-h405.c
135
+
136
SmartFusion2
137
M: Subbaraya Sundeep <sundeep.lkml@gmail.com>
138
M: Peter Maydell <peter.maydell@linaro.org>
139
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
140
index XXXXXXX..XXXXXXX 100644
141
--- a/hw/arm/Kconfig
142
+++ b/hw/arm/Kconfig
143
@@ -XXX,XX +XXX,XX @@ config NETDUINOPLUS2
144
bool
145
select STM32F405_SOC
146
147
+config OLIMEX_STM32_H405
148
+ bool
149
+ select STM32F405_SOC
150
+
151
config NSERIES
152
bool
153
select OMAP
154
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
155
index XXXXXXX..XXXXXXX 100644
156
--- a/hw/arm/meson.build
157
+++ b/hw/arm/meson.build
158
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c'))
159
arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c'))
160
arm_ss.add(when: 'CONFIG_NETDUINO2', if_true: files('netduino2.c'))
161
arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c'))
162
+arm_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c'))
163
arm_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c', 'npcm7xx_boards.c'))
164
arm_ss.add(when: 'CONFIG_NSERIES', if_true: files('nseries.c'))
165
arm_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c'))
73
--
166
--
74
2.25.1
167
2.34.1
75
168
76
169
diff view generated by jsdifflib
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
CCM derived clocks will have to be added later.
3
During SPL boot several Clock Controller Module (CCM) registers are
4
read, most important are PLL and Tuning, as well as divisor registers.
4
5
5
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
6
This patch adds these registers and initializes reset values from user's
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
guide.
8
9
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
10
11
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
12
Message-id: 20221226220303.14420-2-strahinja.p.jankovic@gmail.com
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
14
---
9
hw/misc/imx7_ccm.c | 49 +++++++++++++++++++++++++++++++++++++---------
15
include/hw/arm/allwinner-a10.h | 2 +
10
1 file changed, 40 insertions(+), 9 deletions(-)
16
include/hw/misc/allwinner-a10-ccm.h | 67 +++++++++
17
hw/arm/allwinner-a10.c | 7 +
18
hw/misc/allwinner-a10-ccm.c | 224 ++++++++++++++++++++++++++++
19
hw/arm/Kconfig | 1 +
20
hw/misc/Kconfig | 3 +
21
hw/misc/meson.build | 1 +
22
7 files changed, 305 insertions(+)
23
create mode 100644 include/hw/misc/allwinner-a10-ccm.h
24
create mode 100644 hw/misc/allwinner-a10-ccm.c
11
25
12
diff --git a/hw/misc/imx7_ccm.c b/hw/misc/imx7_ccm.c
26
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
13
index XXXXXXX..XXXXXXX 100644
27
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/misc/imx7_ccm.c
28
--- a/include/hw/arm/allwinner-a10.h
15
+++ b/hw/misc/imx7_ccm.c
29
+++ b/include/hw/arm/allwinner-a10.h
16
@@ -XXX,XX +XXX,XX @@
30
@@ -XXX,XX +XXX,XX @@
17
#include "hw/misc/imx7_ccm.h"
31
#include "hw/usb/hcd-ohci.h"
18
#include "migration/vmstate.h"
32
#include "hw/usb/hcd-ehci.h"
19
33
#include "hw/rtc/allwinner-rtc.h"
20
+#include "trace.h"
34
+#include "hw/misc/allwinner-a10-ccm.h"
21
+
35
22
+#define CKIH_FREQ 24000000 /* 24MHz crystal input */
36
#include "target/arm/cpu.h"
23
+
37
#include "qom/object.h"
24
static void imx7_analog_reset(DeviceState *dev)
38
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
25
{
39
/*< public >*/
26
IMX7AnalogState *s = IMX7_ANALOG(dev);
40
27
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_imx7_ccm = {
41
ARMCPU cpu;
28
static uint32_t imx7_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
42
+ AwA10ClockCtlState ccm;
29
{
43
AwA10PITState timer;
30
/*
44
AwA10PICState intc;
31
- * This function is "consumed" by GPT emulation code, however on
45
AwEmacState emac;
32
- * i.MX7 each GPT block can have their own clock root. This means
46
diff --git a/include/hw/misc/allwinner-a10-ccm.h b/include/hw/misc/allwinner-a10-ccm.h
33
- * that this functions needs somehow to know requester's identity
47
new file mode 100644
34
- * and the way to pass it: be it via additional IMXClk constants
48
index XXXXXXX..XXXXXXX
35
- * or by adding another argument to this method needs to be
49
--- /dev/null
36
- * figured out
50
+++ b/include/hw/misc/allwinner-a10-ccm.h
37
+ * This function is "consumed" by GPT emulation code. Some clocks
51
@@ -XXX,XX +XXX,XX @@
38
+ * have fixed frequencies and we can provide requested frequency
52
+/*
39
+ * easily. However for CCM provided clocks (like IPG) each GPT
53
+ * Allwinner A10 Clock Control Module emulation
40
+ * timer can have its own clock root.
54
+ *
41
+ * This means we need additionnal information when calling this
55
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
42
+ * function to know the requester's identity.
56
+ *
43
*/
57
+ * This file is derived from Allwinner H3 CCU,
44
- qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Not implemented\n",
58
+ * by Niek Linnenbank.
45
- TYPE_IMX7_CCM, __func__);
59
+ *
46
- return 0;
60
+ * This program is free software: you can redistribute it and/or modify
47
+ uint32_t freq = 0;
61
+ * it under the terms of the GNU General Public License as published by
48
+
62
+ * the Free Software Foundation, either version 2 of the License, or
49
+ switch (clock) {
63
+ * (at your option) any later version.
50
+ case CLK_NONE:
64
+ *
65
+ * This program is distributed in the hope that it will be useful,
66
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
67
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
68
+ * GNU General Public License for more details.
69
+ *
70
+ * You should have received a copy of the GNU General Public License
71
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
72
+ */
73
+
74
+#ifndef HW_MISC_ALLWINNER_A10_CCM_H
75
+#define HW_MISC_ALLWINNER_A10_CCM_H
76
+
77
+#include "qom/object.h"
78
+#include "hw/sysbus.h"
79
+
80
+/**
81
+ * @name Constants
82
+ * @{
83
+ */
84
+
85
+/** Size of register I/O address space used by CCM device */
86
+#define AW_A10_CCM_IOSIZE (0x400)
87
+
88
+/** Total number of known registers */
89
+#define AW_A10_CCM_REGS_NUM (AW_A10_CCM_IOSIZE / sizeof(uint32_t))
90
+
91
+/** @} */
92
+
93
+/**
94
+ * @name Object model
95
+ * @{
96
+ */
97
+
98
+#define TYPE_AW_A10_CCM "allwinner-a10-ccm"
99
+OBJECT_DECLARE_SIMPLE_TYPE(AwA10ClockCtlState, AW_A10_CCM)
100
+
101
+/** @} */
102
+
103
+/**
104
+ * Allwinner A10 CCM object instance state.
105
+ */
106
+struct AwA10ClockCtlState {
107
+ /*< private >*/
108
+ SysBusDevice parent_obj;
109
+ /*< public >*/
110
+
111
+ /** Maps I/O registers in physical memory */
112
+ MemoryRegion iomem;
113
+
114
+ /** Array of hardware registers */
115
+ uint32_t regs[AW_A10_CCM_REGS_NUM];
116
+};
117
+
118
+#endif /* HW_MISC_ALLWINNER_H3_CCU_H */
119
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
120
index XXXXXXX..XXXXXXX 100644
121
--- a/hw/arm/allwinner-a10.c
122
+++ b/hw/arm/allwinner-a10.c
123
@@ -XXX,XX +XXX,XX @@
124
#include "hw/usb/hcd-ohci.h"
125
126
#define AW_A10_MMC0_BASE 0x01c0f000
127
+#define AW_A10_CCM_BASE 0x01c20000
128
#define AW_A10_PIC_REG_BASE 0x01c20400
129
#define AW_A10_PIT_REG_BASE 0x01c20c00
130
#define AW_A10_UART0_REG_BASE 0x01c28000
131
@@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj)
132
133
object_initialize_child(obj, "timer", &s->timer, TYPE_AW_A10_PIT);
134
135
+ object_initialize_child(obj, "ccm", &s->ccm, TYPE_AW_A10_CCM);
136
+
137
object_initialize_child(obj, "emac", &s->emac, TYPE_AW_EMAC);
138
139
object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI);
140
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
141
memory_region_add_subregion(get_system_memory(), 0x00000000, &s->sram_a);
142
create_unimplemented_device("a10-sram-ctrl", 0x01c00000, 4 * KiB);
143
144
+ /* Clock Control Module */
145
+ sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &error_fatal);
146
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, AW_A10_CCM_BASE);
147
+
148
/* FIXME use qdev NIC properties instead of nd_table[] */
149
if (nd_table[0].used) {
150
qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC);
151
diff --git a/hw/misc/allwinner-a10-ccm.c b/hw/misc/allwinner-a10-ccm.c
152
new file mode 100644
153
index XXXXXXX..XXXXXXX
154
--- /dev/null
155
+++ b/hw/misc/allwinner-a10-ccm.c
156
@@ -XXX,XX +XXX,XX @@
157
+/*
158
+ * Allwinner A10 Clock Control Module emulation
159
+ *
160
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
161
+ *
162
+ * This file is derived from Allwinner H3 CCU,
163
+ * by Niek Linnenbank.
164
+ *
165
+ * This program is free software: you can redistribute it and/or modify
166
+ * it under the terms of the GNU General Public License as published by
167
+ * the Free Software Foundation, either version 2 of the License, or
168
+ * (at your option) any later version.
169
+ *
170
+ * This program is distributed in the hope that it will be useful,
171
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
172
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
173
+ * GNU General Public License for more details.
174
+ *
175
+ * You should have received a copy of the GNU General Public License
176
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
177
+ */
178
+
179
+#include "qemu/osdep.h"
180
+#include "qemu/units.h"
181
+#include "hw/sysbus.h"
182
+#include "migration/vmstate.h"
183
+#include "qemu/log.h"
184
+#include "qemu/module.h"
185
+#include "hw/misc/allwinner-a10-ccm.h"
186
+
187
+/* CCM register offsets */
188
+enum {
189
+ REG_PLL1_CFG = 0x0000, /* PLL1 Control */
190
+ REG_PLL1_TUN = 0x0004, /* PLL1 Tuning */
191
+ REG_PLL2_CFG = 0x0008, /* PLL2 Control */
192
+ REG_PLL2_TUN = 0x000C, /* PLL2 Tuning */
193
+ REG_PLL3_CFG = 0x0010, /* PLL3 Control */
194
+ REG_PLL4_CFG = 0x0018, /* PLL4 Control */
195
+ REG_PLL5_CFG = 0x0020, /* PLL5 Control */
196
+ REG_PLL5_TUN = 0x0024, /* PLL5 Tuning */
197
+ REG_PLL6_CFG = 0x0028, /* PLL6 Control */
198
+ REG_PLL6_TUN = 0x002C, /* PLL6 Tuning */
199
+ REG_PLL7_CFG = 0x0030, /* PLL7 Control */
200
+ REG_PLL1_TUN2 = 0x0038, /* PLL1 Tuning2 */
201
+ REG_PLL5_TUN2 = 0x003C, /* PLL5 Tuning2 */
202
+ REG_PLL8_CFG = 0x0040, /* PLL8 Control */
203
+ REG_OSC24M_CFG = 0x0050, /* OSC24M Control */
204
+ REG_CPU_AHB_APB0_CFG = 0x0054, /* CPU, AHB and APB0 Divide Ratio */
205
+};
206
+
207
+#define REG_INDEX(offset) (offset / sizeof(uint32_t))
208
+
209
+/* CCM register reset values */
210
+enum {
211
+ REG_PLL1_CFG_RST = 0x21005000,
212
+ REG_PLL1_TUN_RST = 0x0A101000,
213
+ REG_PLL2_CFG_RST = 0x08100010,
214
+ REG_PLL2_TUN_RST = 0x00000000,
215
+ REG_PLL3_CFG_RST = 0x0010D063,
216
+ REG_PLL4_CFG_RST = 0x21009911,
217
+ REG_PLL5_CFG_RST = 0x11049280,
218
+ REG_PLL5_TUN_RST = 0x14888000,
219
+ REG_PLL6_CFG_RST = 0x21009911,
220
+ REG_PLL6_TUN_RST = 0x00000000,
221
+ REG_PLL7_CFG_RST = 0x0010D063,
222
+ REG_PLL1_TUN2_RST = 0x00000000,
223
+ REG_PLL5_TUN2_RST = 0x00000000,
224
+ REG_PLL8_CFG_RST = 0x21009911,
225
+ REG_OSC24M_CFG_RST = 0x00138013,
226
+ REG_CPU_AHB_APB0_CFG_RST = 0x00010010,
227
+};
228
+
229
+static uint64_t allwinner_a10_ccm_read(void *opaque, hwaddr offset,
230
+ unsigned size)
231
+{
232
+ const AwA10ClockCtlState *s = AW_A10_CCM(opaque);
233
+ const uint32_t idx = REG_INDEX(offset);
234
+
235
+ switch (offset) {
236
+ case REG_PLL1_CFG:
237
+ case REG_PLL1_TUN:
238
+ case REG_PLL2_CFG:
239
+ case REG_PLL2_TUN:
240
+ case REG_PLL3_CFG:
241
+ case REG_PLL4_CFG:
242
+ case REG_PLL5_CFG:
243
+ case REG_PLL5_TUN:
244
+ case REG_PLL6_CFG:
245
+ case REG_PLL6_TUN:
246
+ case REG_PLL7_CFG:
247
+ case REG_PLL1_TUN2:
248
+ case REG_PLL5_TUN2:
249
+ case REG_PLL8_CFG:
250
+ case REG_OSC24M_CFG:
251
+ case REG_CPU_AHB_APB0_CFG:
51
+ break;
252
+ break;
52
+ case CLK_32k:
253
+ case 0x158 ... AW_A10_CCM_IOSIZE:
53
+ freq = CKIL_FREQ;
254
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
255
+ __func__, (uint32_t)offset);
256
+ return 0;
257
+ default:
258
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented read offset 0x%04x\n",
259
+ __func__, (uint32_t)offset);
260
+ return 0;
261
+ }
262
+
263
+ return s->regs[idx];
264
+}
265
+
266
+static void allwinner_a10_ccm_write(void *opaque, hwaddr offset,
267
+ uint64_t val, unsigned size)
268
+{
269
+ AwA10ClockCtlState *s = AW_A10_CCM(opaque);
270
+ const uint32_t idx = REG_INDEX(offset);
271
+
272
+ switch (offset) {
273
+ case REG_PLL1_CFG:
274
+ case REG_PLL1_TUN:
275
+ case REG_PLL2_CFG:
276
+ case REG_PLL2_TUN:
277
+ case REG_PLL3_CFG:
278
+ case REG_PLL4_CFG:
279
+ case REG_PLL5_CFG:
280
+ case REG_PLL5_TUN:
281
+ case REG_PLL6_CFG:
282
+ case REG_PLL6_TUN:
283
+ case REG_PLL7_CFG:
284
+ case REG_PLL1_TUN2:
285
+ case REG_PLL5_TUN2:
286
+ case REG_PLL8_CFG:
287
+ case REG_OSC24M_CFG:
288
+ case REG_CPU_AHB_APB0_CFG:
54
+ break;
289
+ break;
55
+ case CLK_HIGH:
290
+ case 0x158 ... AW_A10_CCM_IOSIZE:
56
+ freq = CKIH_FREQ;
291
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
57
+ break;
292
+ __func__, (uint32_t)offset);
58
+ case CLK_IPG:
59
+ case CLK_IPG_HIGH:
60
+ /*
61
+ * For now we don't have a way to figure out the device this
62
+ * function is called for. Until then the IPG derived clocks
63
+ * are left unimplemented.
64
+ */
65
+ qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Clock %d Not implemented\n",
66
+ TYPE_IMX7_CCM, __func__, clock);
67
+ break;
293
+ break;
68
+ default:
294
+ default:
69
+ qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: unsupported clock %d\n",
295
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented write offset 0x%04x\n",
70
+ TYPE_IMX7_CCM, __func__, clock);
296
+ __func__, (uint32_t)offset);
71
+ break;
297
+ break;
72
+ }
298
+ }
73
+
299
+
74
+ trace_ccm_clock_freq(clock, freq);
300
+ s->regs[idx] = (uint32_t) val;
75
+
301
+}
76
+ return freq;
302
+
77
}
303
+static const MemoryRegionOps allwinner_a10_ccm_ops = {
78
304
+ .read = allwinner_a10_ccm_read,
79
static void imx7_ccm_class_init(ObjectClass *klass, void *data)
305
+ .write = allwinner_a10_ccm_write,
306
+ .endianness = DEVICE_NATIVE_ENDIAN,
307
+ .valid = {
308
+ .min_access_size = 4,
309
+ .max_access_size = 4,
310
+ },
311
+ .impl.min_access_size = 4,
312
+};
313
+
314
+static void allwinner_a10_ccm_reset_enter(Object *obj, ResetType type)
315
+{
316
+ AwA10ClockCtlState *s = AW_A10_CCM(obj);
317
+
318
+ /* Set default values for registers */
319
+ s->regs[REG_INDEX(REG_PLL1_CFG)] = REG_PLL1_CFG_RST;
320
+ s->regs[REG_INDEX(REG_PLL1_TUN)] = REG_PLL1_TUN_RST;
321
+ s->regs[REG_INDEX(REG_PLL2_CFG)] = REG_PLL2_CFG_RST;
322
+ s->regs[REG_INDEX(REG_PLL2_TUN)] = REG_PLL2_TUN_RST;
323
+ s->regs[REG_INDEX(REG_PLL3_CFG)] = REG_PLL3_CFG_RST;
324
+ s->regs[REG_INDEX(REG_PLL4_CFG)] = REG_PLL4_CFG_RST;
325
+ s->regs[REG_INDEX(REG_PLL5_CFG)] = REG_PLL5_CFG_RST;
326
+ s->regs[REG_INDEX(REG_PLL5_TUN)] = REG_PLL5_TUN_RST;
327
+ s->regs[REG_INDEX(REG_PLL6_CFG)] = REG_PLL6_CFG_RST;
328
+ s->regs[REG_INDEX(REG_PLL6_TUN)] = REG_PLL6_TUN_RST;
329
+ s->regs[REG_INDEX(REG_PLL7_CFG)] = REG_PLL7_CFG_RST;
330
+ s->regs[REG_INDEX(REG_PLL1_TUN2)] = REG_PLL1_TUN2_RST;
331
+ s->regs[REG_INDEX(REG_PLL5_TUN2)] = REG_PLL5_TUN2_RST;
332
+ s->regs[REG_INDEX(REG_PLL8_CFG)] = REG_PLL8_CFG_RST;
333
+ s->regs[REG_INDEX(REG_OSC24M_CFG)] = REG_OSC24M_CFG_RST;
334
+ s->regs[REG_INDEX(REG_CPU_AHB_APB0_CFG)] = REG_CPU_AHB_APB0_CFG_RST;
335
+}
336
+
337
+static void allwinner_a10_ccm_init(Object *obj)
338
+{
339
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
340
+ AwA10ClockCtlState *s = AW_A10_CCM(obj);
341
+
342
+ /* Memory mapping */
343
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_a10_ccm_ops, s,
344
+ TYPE_AW_A10_CCM, AW_A10_CCM_IOSIZE);
345
+ sysbus_init_mmio(sbd, &s->iomem);
346
+}
347
+
348
+static const VMStateDescription allwinner_a10_ccm_vmstate = {
349
+ .name = "allwinner-a10-ccm",
350
+ .version_id = 1,
351
+ .minimum_version_id = 1,
352
+ .fields = (VMStateField[]) {
353
+ VMSTATE_UINT32_ARRAY(regs, AwA10ClockCtlState, AW_A10_CCM_REGS_NUM),
354
+ VMSTATE_END_OF_LIST()
355
+ }
356
+};
357
+
358
+static void allwinner_a10_ccm_class_init(ObjectClass *klass, void *data)
359
+{
360
+ DeviceClass *dc = DEVICE_CLASS(klass);
361
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
362
+
363
+ rc->phases.enter = allwinner_a10_ccm_reset_enter;
364
+ dc->vmsd = &allwinner_a10_ccm_vmstate;
365
+}
366
+
367
+static const TypeInfo allwinner_a10_ccm_info = {
368
+ .name = TYPE_AW_A10_CCM,
369
+ .parent = TYPE_SYS_BUS_DEVICE,
370
+ .instance_init = allwinner_a10_ccm_init,
371
+ .instance_size = sizeof(AwA10ClockCtlState),
372
+ .class_init = allwinner_a10_ccm_class_init,
373
+};
374
+
375
+static void allwinner_a10_ccm_register(void)
376
+{
377
+ type_register_static(&allwinner_a10_ccm_info);
378
+}
379
+
380
+type_init(allwinner_a10_ccm_register)
381
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
382
index XXXXXXX..XXXXXXX 100644
383
--- a/hw/arm/Kconfig
384
+++ b/hw/arm/Kconfig
385
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
386
select AHCI
387
select ALLWINNER_A10_PIT
388
select ALLWINNER_A10_PIC
389
+ select ALLWINNER_A10_CCM
390
select ALLWINNER_EMAC
391
select SERIAL
392
select UNIMP
393
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
394
index XXXXXXX..XXXXXXX 100644
395
--- a/hw/misc/Kconfig
396
+++ b/hw/misc/Kconfig
397
@@ -XXX,XX +XXX,XX @@ config VIRT_CTRL
398
config LASI
399
bool
400
401
+config ALLWINNER_A10_CCM
402
+ bool
403
+
404
source macio/Kconfig
405
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
406
index XXXXXXX..XXXXXXX 100644
407
--- a/hw/misc/meson.build
408
+++ b/hw/misc/meson.build
409
@@ -XXX,XX +XXX,XX @@ subdir('macio')
410
411
softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c'))
412
413
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c'))
414
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
415
specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'))
416
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
80
--
417
--
81
2.25.1
418
2.34.1
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
3
During SPL boot several DRAM Controller registers are used. Most
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
important registers are those related to DRAM initialization and
5
calibration, where SPL initiates process and waits until certain bit is
6
set/cleared.
7
8
This patch adds these registers, initializes reset values from user's
9
guide and updates state of registers as SPL expects it.
10
11
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
12
13
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
14
Message-id: 20221226220303.14420-3-strahinja.p.jankovic@gmail.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
---
16
---
7
hw/timer/imx_epit.c | 215 ++++++++++++++++++++++++--------------------
17
include/hw/arm/allwinner-a10.h | 2 +
8
1 file changed, 117 insertions(+), 98 deletions(-)
18
include/hw/misc/allwinner-a10-dramc.h | 68 ++++++++++
9
19
hw/arm/allwinner-a10.c | 7 +
10
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
20
hw/misc/allwinner-a10-dramc.c | 179 ++++++++++++++++++++++++++
11
index XXXXXXX..XXXXXXX 100644
21
hw/arm/Kconfig | 1 +
12
--- a/hw/timer/imx_epit.c
22
hw/misc/Kconfig | 3 +
13
+++ b/hw/timer/imx_epit.c
23
hw/misc/meson.build | 1 +
14
@@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s)
24
7 files changed, 261 insertions(+)
15
}
25
create mode 100644 include/hw/misc/allwinner-a10-dramc.h
16
}
26
create mode 100644 hw/misc/allwinner-a10-dramc.c
17
27
18
+static void imx_epit_write_cr(IMXEPITState *s, uint32_t value)
28
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
19
+{
29
index XXXXXXX..XXXXXXX 100644
20
+ uint32_t oldcr = s->cr;
30
--- a/include/hw/arm/allwinner-a10.h
21
+
31
+++ b/include/hw/arm/allwinner-a10.h
22
+ s->cr = value & 0x03ffffff;
32
@@ -XXX,XX +XXX,XX @@
23
+
33
#include "hw/usb/hcd-ehci.h"
24
+ if (s->cr & CR_SWR) {
34
#include "hw/rtc/allwinner-rtc.h"
25
+ /* handle the reset */
35
#include "hw/misc/allwinner-a10-ccm.h"
26
+ imx_epit_reset(s, false);
36
+#include "hw/misc/allwinner-a10-dramc.h"
37
38
#include "target/arm/cpu.h"
39
#include "qom/object.h"
40
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
41
42
ARMCPU cpu;
43
AwA10ClockCtlState ccm;
44
+ AwA10DramControllerState dramc;
45
AwA10PITState timer;
46
AwA10PICState intc;
47
AwEmacState emac;
48
diff --git a/include/hw/misc/allwinner-a10-dramc.h b/include/hw/misc/allwinner-a10-dramc.h
49
new file mode 100644
50
index XXXXXXX..XXXXXXX
51
--- /dev/null
52
+++ b/include/hw/misc/allwinner-a10-dramc.h
53
@@ -XXX,XX +XXX,XX @@
54
+/*
55
+ * Allwinner A10 DRAM Controller emulation
56
+ *
57
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
58
+ *
59
+ * This file is derived from Allwinner H3 DRAMC,
60
+ * by Niek Linnenbank.
61
+ *
62
+ * This program is free software: you can redistribute it and/or modify
63
+ * it under the terms of the GNU General Public License as published by
64
+ * the Free Software Foundation, either version 2 of the License, or
65
+ * (at your option) any later version.
66
+ *
67
+ * This program is distributed in the hope that it will be useful,
68
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
69
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
70
+ * GNU General Public License for more details.
71
+ *
72
+ * You should have received a copy of the GNU General Public License
73
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
74
+ */
75
+
76
+#ifndef HW_MISC_ALLWINNER_A10_DRAMC_H
77
+#define HW_MISC_ALLWINNER_A10_DRAMC_H
78
+
79
+#include "qom/object.h"
80
+#include "hw/sysbus.h"
81
+#include "hw/register.h"
82
+
83
+/**
84
+ * @name Constants
85
+ * @{
86
+ */
87
+
88
+/** Size of register I/O address space used by DRAMC device */
89
+#define AW_A10_DRAMC_IOSIZE (0x1000)
90
+
91
+/** Total number of known registers */
92
+#define AW_A10_DRAMC_REGS_NUM (AW_A10_DRAMC_IOSIZE / sizeof(uint32_t))
93
+
94
+/** @} */
95
+
96
+/**
97
+ * @name Object model
98
+ * @{
99
+ */
100
+
101
+#define TYPE_AW_A10_DRAMC "allwinner-a10-dramc"
102
+OBJECT_DECLARE_SIMPLE_TYPE(AwA10DramControllerState, AW_A10_DRAMC)
103
+
104
+/** @} */
105
+
106
+/**
107
+ * Allwinner A10 DRAMC object instance state.
108
+ */
109
+struct AwA10DramControllerState {
110
+ /*< private >*/
111
+ SysBusDevice parent_obj;
112
+ /*< public >*/
113
+
114
+ /** Maps I/O registers in physical memory */
115
+ MemoryRegion iomem;
116
+
117
+ /** Array of hardware registers */
118
+ uint32_t regs[AW_A10_DRAMC_REGS_NUM];
119
+};
120
+
121
+#endif /* HW_MISC_ALLWINNER_A10_DRAMC_H */
122
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
123
index XXXXXXX..XXXXXXX 100644
124
--- a/hw/arm/allwinner-a10.c
125
+++ b/hw/arm/allwinner-a10.c
126
@@ -XXX,XX +XXX,XX @@
127
#include "hw/boards.h"
128
#include "hw/usb/hcd-ohci.h"
129
130
+#define AW_A10_DRAMC_BASE 0x01c01000
131
#define AW_A10_MMC0_BASE 0x01c0f000
132
#define AW_A10_CCM_BASE 0x01c20000
133
#define AW_A10_PIC_REG_BASE 0x01c20400
134
@@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj)
135
136
object_initialize_child(obj, "ccm", &s->ccm, TYPE_AW_A10_CCM);
137
138
+ object_initialize_child(obj, "dramc", &s->dramc, TYPE_AW_A10_DRAMC);
139
+
140
object_initialize_child(obj, "emac", &s->emac, TYPE_AW_EMAC);
141
142
object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI);
143
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
144
sysbus_realize(SYS_BUS_DEVICE(&s->ccm), &error_fatal);
145
sysbus_mmio_map(SYS_BUS_DEVICE(&s->ccm), 0, AW_A10_CCM_BASE);
146
147
+ /* DRAM Control Module */
148
+ sysbus_realize(SYS_BUS_DEVICE(&s->dramc), &error_fatal);
149
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->dramc), 0, AW_A10_DRAMC_BASE);
150
+
151
/* FIXME use qdev NIC properties instead of nd_table[] */
152
if (nd_table[0].used) {
153
qemu_check_nic_model(&nd_table[0], TYPE_AW_EMAC);
154
diff --git a/hw/misc/allwinner-a10-dramc.c b/hw/misc/allwinner-a10-dramc.c
155
new file mode 100644
156
index XXXXXXX..XXXXXXX
157
--- /dev/null
158
+++ b/hw/misc/allwinner-a10-dramc.c
159
@@ -XXX,XX +XXX,XX @@
160
+/*
161
+ * Allwinner A10 DRAM Controller emulation
162
+ *
163
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
164
+ *
165
+ * This file is derived from Allwinner H3 DRAMC,
166
+ * by Niek Linnenbank.
167
+ *
168
+ * This program is free software: you can redistribute it and/or modify
169
+ * it under the terms of the GNU General Public License as published by
170
+ * the Free Software Foundation, either version 2 of the License, or
171
+ * (at your option) any later version.
172
+ *
173
+ * This program is distributed in the hope that it will be useful,
174
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
175
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
176
+ * GNU General Public License for more details.
177
+ *
178
+ * You should have received a copy of the GNU General Public License
179
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
180
+ */
181
+
182
+#include "qemu/osdep.h"
183
+#include "qemu/units.h"
184
+#include "hw/sysbus.h"
185
+#include "migration/vmstate.h"
186
+#include "qemu/log.h"
187
+#include "qemu/module.h"
188
+#include "hw/misc/allwinner-a10-dramc.h"
189
+
190
+/* DRAMC register offsets */
191
+enum {
192
+ REG_SDR_CCR = 0x0000,
193
+ REG_SDR_ZQCR0 = 0x00a8,
194
+ REG_SDR_ZQSR = 0x00b0
195
+};
196
+
197
+#define REG_INDEX(offset) (offset / sizeof(uint32_t))
198
+
199
+/* DRAMC register flags */
200
+enum {
201
+ REG_SDR_CCR_DATA_TRAINING = (1 << 30),
202
+ REG_SDR_CCR_DRAM_INIT = (1 << 31),
203
+};
204
+enum {
205
+ REG_SDR_ZQSR_ZCAL = (1 << 31),
206
+};
207
+
208
+/* DRAMC register reset values */
209
+enum {
210
+ REG_SDR_CCR_RESET = 0x80020000,
211
+ REG_SDR_ZQCR0_RESET = 0x07b00000,
212
+ REG_SDR_ZQSR_RESET = 0x80000000
213
+};
214
+
215
+static uint64_t allwinner_a10_dramc_read(void *opaque, hwaddr offset,
216
+ unsigned size)
217
+{
218
+ const AwA10DramControllerState *s = AW_A10_DRAMC(opaque);
219
+ const uint32_t idx = REG_INDEX(offset);
220
+
221
+ switch (offset) {
222
+ case REG_SDR_CCR:
223
+ case REG_SDR_ZQCR0:
224
+ case REG_SDR_ZQSR:
225
+ break;
226
+ case 0x2e4 ... AW_A10_DRAMC_IOSIZE:
227
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
228
+ __func__, (uint32_t)offset);
229
+ return 0;
230
+ default:
231
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented read offset 0x%04x\n",
232
+ __func__, (uint32_t)offset);
233
+ return 0;
27
+ }
234
+ }
28
+
235
+
29
+ /*
236
+ return s->regs[idx];
30
+ * The interrupt state can change due to:
237
+}
31
+ * - reset clears both SR.OCIF and CR.OCIE
238
+
32
+ * - write to CR.EN or CR.OCIE
239
+static void allwinner_a10_dramc_write(void *opaque, hwaddr offset,
33
+ */
240
+ uint64_t val, unsigned size)
34
+ imx_epit_update_int(s);
241
+{
35
+
242
+ AwA10DramControllerState *s = AW_A10_DRAMC(opaque);
36
+ /*
243
+ const uint32_t idx = REG_INDEX(offset);
37
+ * TODO: could we 'break' here for reset? following operations appear
244
+
38
+ * to duplicate the work imx_epit_reset() already did.
245
+ switch (offset) {
39
+ */
246
+ case REG_SDR_CCR:
40
+
247
+ if (val & REG_SDR_CCR_DRAM_INIT) {
41
+ ptimer_transaction_begin(s->timer_cmp);
248
+ /* Clear DRAM_INIT to indicate process is done. */
42
+ ptimer_transaction_begin(s->timer_reload);
249
+ val &= ~REG_SDR_CCR_DRAM_INIT;
43
+
250
+ }
44
+ /* Update the frequency. Has been done already in case of a reset. */
251
+ if (val & REG_SDR_CCR_DATA_TRAINING) {
45
+ if (!(s->cr & CR_SWR)) {
252
+ /* Clear DATA_TRAINING to indicate process is done. */
46
+ imx_epit_set_freq(s);
253
+ val &= ~REG_SDR_CCR_DATA_TRAINING;
254
+ }
255
+ break;
256
+ case REG_SDR_ZQCR0:
257
+ /* Set ZCAL in ZQSR to indicate calibration is done. */
258
+ s->regs[REG_INDEX(REG_SDR_ZQSR)] |= REG_SDR_ZQSR_ZCAL;
259
+ break;
260
+ case 0x2e4 ... AW_A10_DRAMC_IOSIZE:
261
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
262
+ __func__, (uint32_t)offset);
263
+ break;
264
+ default:
265
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented write offset 0x%04x\n",
266
+ __func__, (uint32_t)offset);
267
+ break;
47
+ }
268
+ }
48
+
269
+
49
+ if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {
270
+ s->regs[idx] = (uint32_t) val;
50
+ if (s->cr & CR_ENMOD) {
271
+}
51
+ if (s->cr & CR_RLD) {
272
+
52
+ ptimer_set_limit(s->timer_reload, s->lr, 1);
273
+static const MemoryRegionOps allwinner_a10_dramc_ops = {
53
+ ptimer_set_limit(s->timer_cmp, s->lr, 1);
274
+ .read = allwinner_a10_dramc_read,
54
+ } else {
275
+ .write = allwinner_a10_dramc_write,
55
+ ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1);
276
+ .endianness = DEVICE_NATIVE_ENDIAN,
56
+ ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1);
277
+ .valid = {
57
+ }
278
+ .min_access_size = 4,
58
+ }
279
+ .max_access_size = 4,
59
+
280
+ },
60
+ imx_epit_reload_compare_timer(s);
281
+ .impl.min_access_size = 4,
61
+ ptimer_run(s->timer_reload, 0);
282
+};
62
+ if (s->cr & CR_OCIEN) {
283
+
63
+ ptimer_run(s->timer_cmp, 0);
284
+static void allwinner_a10_dramc_reset_enter(Object *obj, ResetType type)
64
+ } else {
285
+{
65
+ ptimer_stop(s->timer_cmp);
286
+ AwA10DramControllerState *s = AW_A10_DRAMC(obj);
66
+ }
287
+
67
+ } else if (!(s->cr & CR_EN)) {
288
+ /* Set default values for registers */
68
+ /* stop both timers */
289
+ s->regs[REG_INDEX(REG_SDR_CCR)] = REG_SDR_CCR_RESET;
69
+ ptimer_stop(s->timer_reload);
290
+ s->regs[REG_INDEX(REG_SDR_ZQCR0)] = REG_SDR_ZQCR0_RESET;
70
+ ptimer_stop(s->timer_cmp);
291
+ s->regs[REG_INDEX(REG_SDR_ZQSR)] = REG_SDR_ZQSR_RESET;
71
+ } else if (s->cr & CR_OCIEN) {
292
+}
72
+ if (!(oldcr & CR_OCIEN)) {
293
+
73
+ imx_epit_reload_compare_timer(s);
294
+static void allwinner_a10_dramc_init(Object *obj)
74
+ ptimer_run(s->timer_cmp, 0);
295
+{
75
+ }
296
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
76
+ } else {
297
+ AwA10DramControllerState *s = AW_A10_DRAMC(obj);
77
+ ptimer_stop(s->timer_cmp);
298
+
299
+ /* Memory mapping */
300
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_a10_dramc_ops, s,
301
+ TYPE_AW_A10_DRAMC, AW_A10_DRAMC_IOSIZE);
302
+ sysbus_init_mmio(sbd, &s->iomem);
303
+}
304
+
305
+static const VMStateDescription allwinner_a10_dramc_vmstate = {
306
+ .name = "allwinner-a10-dramc",
307
+ .version_id = 1,
308
+ .minimum_version_id = 1,
309
+ .fields = (VMStateField[]) {
310
+ VMSTATE_UINT32_ARRAY(regs, AwA10DramControllerState,
311
+ AW_A10_DRAMC_REGS_NUM),
312
+ VMSTATE_END_OF_LIST()
78
+ }
313
+ }
79
+
314
+};
80
+ ptimer_transaction_commit(s->timer_cmp);
315
+
81
+ ptimer_transaction_commit(s->timer_reload);
316
+static void allwinner_a10_dramc_class_init(ObjectClass *klass, void *data)
82
+}
317
+{
83
+
318
+ DeviceClass *dc = DEVICE_CLASS(klass);
84
+static void imx_epit_write_sr(IMXEPITState *s, uint32_t value)
319
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
85
+{
320
+
86
+ /* writing 1 to SR.OCIF clears this bit and turns the interrupt off */
321
+ rc->phases.enter = allwinner_a10_dramc_reset_enter;
87
+ if (value & SR_OCIF) {
322
+ dc->vmsd = &allwinner_a10_dramc_vmstate;
88
+ s->sr = 0; /* SR.OCIF is the only bit in this register anyway */
323
+}
89
+ imx_epit_update_int(s);
324
+
90
+ }
325
+static const TypeInfo allwinner_a10_dramc_info = {
91
+}
326
+ .name = TYPE_AW_A10_DRAMC,
92
+
327
+ .parent = TYPE_SYS_BUS_DEVICE,
93
+static void imx_epit_write_lr(IMXEPITState *s, uint32_t value)
328
+ .instance_init = allwinner_a10_dramc_init,
94
+{
329
+ .instance_size = sizeof(AwA10DramControllerState),
95
+ s->lr = value;
330
+ .class_init = allwinner_a10_dramc_class_init,
96
+
331
+};
97
+ ptimer_transaction_begin(s->timer_cmp);
332
+
98
+ ptimer_transaction_begin(s->timer_reload);
333
+static void allwinner_a10_dramc_register(void)
99
+ if (s->cr & CR_RLD) {
334
+{
100
+ /* Also set the limit if the LRD bit is set */
335
+ type_register_static(&allwinner_a10_dramc_info);
101
+ /* If IOVW bit is set then set the timer value */
336
+}
102
+ ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW);
337
+
103
+ ptimer_set_limit(s->timer_cmp, s->lr, 0);
338
+type_init(allwinner_a10_dramc_register)
104
+ } else if (s->cr & CR_IOVW) {
339
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
105
+ /* If IOVW bit is set then set the timer value */
340
index XXXXXXX..XXXXXXX 100644
106
+ ptimer_set_count(s->timer_reload, s->lr);
341
--- a/hw/arm/Kconfig
107
+ }
342
+++ b/hw/arm/Kconfig
108
+ /*
343
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
109
+ * Commit the change to s->timer_reload, so it can propagate. Otherwise
344
select ALLWINNER_A10_PIT
110
+ * the timer interrupt may not fire properly. The commit must happen
345
select ALLWINNER_A10_PIC
111
+ * before calling imx_epit_reload_compare_timer(), which reads
346
select ALLWINNER_A10_CCM
112
+ * s->timer_reload internally again.
347
+ select ALLWINNER_A10_DRAMC
113
+ */
348
select ALLWINNER_EMAC
114
+ ptimer_transaction_commit(s->timer_reload);
349
select SERIAL
115
+ imx_epit_reload_compare_timer(s);
350
select UNIMP
116
+ ptimer_transaction_commit(s->timer_cmp);
351
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
117
+}
352
index XXXXXXX..XXXXXXX 100644
118
+
353
--- a/hw/misc/Kconfig
119
+static void imx_epit_write_cmp(IMXEPITState *s, uint32_t value)
354
+++ b/hw/misc/Kconfig
120
+{
355
@@ -XXX,XX +XXX,XX @@ config LASI
121
+ s->cmp = value;
356
config ALLWINNER_A10_CCM
122
+
357
bool
123
+ ptimer_transaction_begin(s->timer_cmp);
358
124
+ imx_epit_reload_compare_timer(s);
359
+config ALLWINNER_A10_DRAMC
125
+ ptimer_transaction_commit(s->timer_cmp);
360
+ bool
126
+}
361
+
127
+
362
source macio/Kconfig
128
static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
363
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
129
unsigned size)
364
index XXXXXXX..XXXXXXX 100644
130
{
365
--- a/hw/misc/meson.build
131
IMXEPITState *s = IMX_EPIT(opaque);
366
+++ b/hw/misc/meson.build
132
- uint64_t oldcr;
367
@@ -XXX,XX +XXX,XX @@ subdir('macio')
133
368
softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c'))
134
DPRINTF("(%s, value = 0x%08x)\n", imx_epit_reg_name(offset >> 2),
369
135
(uint32_t)value);
370
softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c'))
136
371
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_DRAMC', if_true: files('allwinner-a10-dramc.c'))
137
switch (offset >> 2) {
372
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
138
case 0: /* CR */
373
specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'))
139
-
374
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
140
- oldcr = s->cr;
141
- s->cr = value & 0x03ffffff;
142
- if (s->cr & CR_SWR) {
143
- /* handle the reset */
144
- imx_epit_reset(s, false);
145
- }
146
-
147
- /*
148
- * The interrupt state can change due to:
149
- * - reset clears both SR.OCIF and CR.OCIE
150
- * - write to CR.EN or CR.OCIE
151
- */
152
- imx_epit_update_int(s);
153
-
154
- /*
155
- * TODO: could we 'break' here for reset? following operations appear
156
- * to duplicate the work imx_epit_reset() already did.
157
- */
158
-
159
- ptimer_transaction_begin(s->timer_cmp);
160
- ptimer_transaction_begin(s->timer_reload);
161
-
162
- /* Update the frequency. Has been done already in case of a reset. */
163
- if (!(s->cr & CR_SWR)) {
164
- imx_epit_set_freq(s);
165
- }
166
-
167
- if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {
168
- if (s->cr & CR_ENMOD) {
169
- if (s->cr & CR_RLD) {
170
- ptimer_set_limit(s->timer_reload, s->lr, 1);
171
- ptimer_set_limit(s->timer_cmp, s->lr, 1);
172
- } else {
173
- ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1);
174
- ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1);
175
- }
176
- }
177
-
178
- imx_epit_reload_compare_timer(s);
179
- ptimer_run(s->timer_reload, 0);
180
- if (s->cr & CR_OCIEN) {
181
- ptimer_run(s->timer_cmp, 0);
182
- } else {
183
- ptimer_stop(s->timer_cmp);
184
- }
185
- } else if (!(s->cr & CR_EN)) {
186
- /* stop both timers */
187
- ptimer_stop(s->timer_reload);
188
- ptimer_stop(s->timer_cmp);
189
- } else if (s->cr & CR_OCIEN) {
190
- if (!(oldcr & CR_OCIEN)) {
191
- imx_epit_reload_compare_timer(s);
192
- ptimer_run(s->timer_cmp, 0);
193
- }
194
- } else {
195
- ptimer_stop(s->timer_cmp);
196
- }
197
-
198
- ptimer_transaction_commit(s->timer_cmp);
199
- ptimer_transaction_commit(s->timer_reload);
200
+ imx_epit_write_cr(s, (uint32_t)value);
201
break;
202
203
- case 1: /* SR - ACK*/
204
- /* writing 1 to SR.OCIF clears this bit and turns the interrupt off */
205
- if (value & SR_OCIF) {
206
- s->sr = 0; /* SR.OCIF is the only bit in this register anyway */
207
- imx_epit_update_int(s);
208
- }
209
+ case 1: /* SR */
210
+ imx_epit_write_sr(s, (uint32_t)value);
211
break;
212
213
- case 2: /* LR - set ticks */
214
- s->lr = value;
215
-
216
- ptimer_transaction_begin(s->timer_cmp);
217
- ptimer_transaction_begin(s->timer_reload);
218
- if (s->cr & CR_RLD) {
219
- /* Also set the limit if the LRD bit is set */
220
- /* If IOVW bit is set then set the timer value */
221
- ptimer_set_limit(s->timer_reload, s->lr, s->cr & CR_IOVW);
222
- ptimer_set_limit(s->timer_cmp, s->lr, 0);
223
- } else if (s->cr & CR_IOVW) {
224
- /* If IOVW bit is set then set the timer value */
225
- ptimer_set_count(s->timer_reload, s->lr);
226
- }
227
- /*
228
- * Commit the change to s->timer_reload, so it can propagate. Otherwise
229
- * the timer interrupt may not fire properly. The commit must happen
230
- * before calling imx_epit_reload_compare_timer(), which reads
231
- * s->timer_reload internally again.
232
- */
233
- ptimer_transaction_commit(s->timer_reload);
234
- imx_epit_reload_compare_timer(s);
235
- ptimer_transaction_commit(s->timer_cmp);
236
+ case 2: /* LR */
237
+ imx_epit_write_lr(s, (uint32_t)value);
238
break;
239
240
case 3: /* CMP */
241
- s->cmp = value;
242
-
243
- ptimer_transaction_begin(s->timer_cmp);
244
- imx_epit_reload_compare_timer(s);
245
- ptimer_transaction_commit(s->timer_cmp);
246
-
247
+ imx_epit_write_cmp(s, (uint32_t)value);
248
break;
249
250
default:
251
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
252
HWADDR_PRIx "\n", TYPE_IMX_EPIT, __func__, offset);
253
-
254
break;
255
}
256
}
257
+
258
static void imx_epit_cmp(void *opaque)
259
{
260
IMXEPITState *s = IMX_EPIT(opaque);
261
--
375
--
262
2.25.1
376
2.34.1
diff view generated by jsdifflib
1
From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
3
This patch implements Allwinner TWI/I2C controller emulation. Only
4
Message-id: 20221206102504.165775-6-tobias.roehmel@rwth-aachen.de
4
master-mode functionality is implemented.
5
6
The SPL boot for Cubieboard expects AXP209 PMIC on TWI0/I2C0 bus, so this is
7
first part enabling the TWI/I2C bus operation.
8
9
Since both Allwinner A10 and H3 use the same module, it is added for
10
both boards.
11
12
Docs are also updated for Cubieboard and Orangepi-PC board to indicate
13
I2C availability.
14
15
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
16
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
17
Message-id: 20221226220303.14420-4-strahinja.p.jankovic@gmail.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
---
19
---
7
target/arm/cpu.h | 6 +
20
docs/system/arm/cubieboard.rst | 1 +
8
target/arm/cpu.c | 28 +++-
21
docs/system/arm/orangepi.rst | 1 +
9
target/arm/helper.c | 302 +++++++++++++++++++++++++++++++++++++++++++
22
include/hw/arm/allwinner-a10.h | 2 +
10
target/arm/machine.c | 28 ++++
23
include/hw/arm/allwinner-h3.h | 3 +
11
4 files changed, 360 insertions(+), 4 deletions(-)
24
include/hw/i2c/allwinner-i2c.h | 55 ++++
25
hw/arm/allwinner-a10.c | 8 +
26
hw/arm/allwinner-h3.c | 11 +-
27
hw/i2c/allwinner-i2c.c | 459 +++++++++++++++++++++++++++++++++
28
hw/arm/Kconfig | 2 +
29
hw/i2c/Kconfig | 4 +
30
hw/i2c/meson.build | 1 +
31
hw/i2c/trace-events | 5 +
32
12 files changed, 551 insertions(+), 1 deletion(-)
33
create mode 100644 include/hw/i2c/allwinner-i2c.h
34
create mode 100644 hw/i2c/allwinner-i2c.c
12
35
13
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
36
diff --git a/docs/system/arm/cubieboard.rst b/docs/system/arm/cubieboard.rst
14
index XXXXXXX..XXXXXXX 100644
37
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/cpu.h
38
--- a/docs/system/arm/cubieboard.rst
16
+++ b/target/arm/cpu.h
39
+++ b/docs/system/arm/cubieboard.rst
17
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
40
@@ -XXX,XX +XXX,XX @@ Emulated devices:
18
};
41
- SDHCI
19
uint64_t sctlr_el[4];
42
- USB controller
20
};
43
- SATA controller
21
+ uint64_t vsctlr; /* Virtualization System control register. */
44
+- TWI (I2C) controller
22
uint64_t cpacr_el1; /* Architectural feature access control register */
45
diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst
23
uint64_t cptr_el[4]; /* ARMv8 feature trap registers */
46
index XXXXXXX..XXXXXXX 100644
24
uint32_t c1_xscaleauxcr; /* XScale auxiliary control register. */
47
--- a/docs/system/arm/orangepi.rst
25
@@ -XXX,XX +XXX,XX @@ typedef struct CPUArchState {
48
+++ b/docs/system/arm/orangepi.rst
26
*/
49
@@ -XXX,XX +XXX,XX @@ The Orange Pi PC machine supports the following devices:
27
uint32_t *rbar[M_REG_NUM_BANKS];
50
* Clock Control Unit
28
uint32_t *rlar[M_REG_NUM_BANKS];
51
* System Control module
29
+ uint32_t *hprbar;
52
* Security Identifier device
30
+ uint32_t *hprlar;
53
+ * TWI (I2C)
31
uint32_t mair0[M_REG_NUM_BANKS];
54
32
uint32_t mair1[M_REG_NUM_BANKS];
55
Limitations
33
+ uint32_t hprselr;
56
"""""""""""
34
} pmsav8;
57
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
35
58
index XXXXXXX..XXXXXXX 100644
36
/* v8M SAU */
59
--- a/include/hw/arm/allwinner-a10.h
37
@@ -XXX,XX +XXX,XX @@ struct ArchCPU {
60
+++ b/include/hw/arm/allwinner-a10.h
38
bool has_mpu;
61
@@ -XXX,XX +XXX,XX @@
39
/* PMSAv7 MPU number of supported regions */
62
#include "hw/rtc/allwinner-rtc.h"
40
uint32_t pmsav7_dregion;
63
#include "hw/misc/allwinner-a10-ccm.h"
41
+ /* PMSAv8 MPU number of supported hyp regions */
64
#include "hw/misc/allwinner-a10-dramc.h"
42
+ uint32_t pmsav8r_hdregion;
65
+#include "hw/i2c/allwinner-i2c.h"
43
/* v8M SAU number of supported regions */
66
44
uint32_t sau_sregion;
67
#include "target/arm/cpu.h"
45
68
#include "qom/object.h"
46
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
69
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
47
index XXXXXXX..XXXXXXX 100644
70
AwEmacState emac;
48
--- a/target/arm/cpu.c
71
AllwinnerAHCIState sata;
49
+++ b/target/arm/cpu.c
72
AwSdHostState mmc0;
50
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj)
73
+ AWI2CState i2c0;
51
sizeof(*env->pmsav7.dracr) * cpu->pmsav7_dregion);
74
AwRtcState rtc;
52
}
75
MemoryRegion sram_a;
53
}
76
EHCISysBusState ehci[AW_A10_NUM_USB];
54
+
77
diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h
55
+ if (cpu->pmsav8r_hdregion > 0) {
78
index XXXXXXX..XXXXXXX 100644
56
+ memset(env->pmsav8.hprbar, 0,
79
--- a/include/hw/arm/allwinner-h3.h
57
+ sizeof(*env->pmsav8.hprbar) * cpu->pmsav8r_hdregion);
80
+++ b/include/hw/arm/allwinner-h3.h
58
+ memset(env->pmsav8.hprlar, 0,
81
@@ -XXX,XX +XXX,XX @@
59
+ sizeof(*env->pmsav8.hprlar) * cpu->pmsav8r_hdregion);
82
#include "hw/sd/allwinner-sdhost.h"
60
+ }
83
#include "hw/net/allwinner-sun8i-emac.h"
61
+
84
#include "hw/rtc/allwinner-rtc.h"
62
env->pmsav7.rnr[M_REG_NS] = 0;
85
+#include "hw/i2c/allwinner-i2c.h"
63
env->pmsav7.rnr[M_REG_S] = 0;
86
#include "target/arm/cpu.h"
64
env->pmsav8.mair0[M_REG_NS] = 0;
87
#include "sysemu/block-backend.h"
65
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
88
66
/* MPU can be configured out of a PMSA CPU either by setting has-mpu
89
@@ -XXX,XX +XXX,XX @@ enum {
67
* to false or by setting pmsav7-dregion to 0.
90
AW_H3_DEV_UART2,
68
*/
91
AW_H3_DEV_UART3,
69
- if (!cpu->has_mpu) {
92
AW_H3_DEV_EMAC,
70
- cpu->pmsav7_dregion = 0;
93
+ AW_H3_DEV_TWI0,
71
- }
94
AW_H3_DEV_DRAMCOM,
72
- if (cpu->pmsav7_dregion == 0) {
95
AW_H3_DEV_DRAMCTL,
73
+ if (!cpu->has_mpu || cpu->pmsav7_dregion == 0) {
96
AW_H3_DEV_DRAMPHY,
74
cpu->has_mpu = false;
97
@@ -XXX,XX +XXX,XX @@ struct AwH3State {
75
+ cpu->pmsav7_dregion = 0;
98
AwH3SysCtrlState sysctrl;
76
+ cpu->pmsav8r_hdregion = 0;
99
AwSidState sid;
77
}
100
AwSdHostState mmc0;
78
101
+ AWI2CState i2c0;
79
if (arm_feature(env, ARM_FEATURE_PMSA) &&
102
AwSun8iEmacState emac;
80
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
103
AwRtcState rtc;
81
env->pmsav7.dracr = g_new0(uint32_t, nr);
104
GICState gic;
82
}
105
diff --git a/include/hw/i2c/allwinner-i2c.h b/include/hw/i2c/allwinner-i2c.h
83
}
106
new file mode 100644
84
+
107
index XXXXXXX..XXXXXXX
85
+ if (cpu->pmsav8r_hdregion > 0xff) {
108
--- /dev/null
86
+ error_setg(errp, "PMSAv8 MPU EL2 #regions invalid %" PRIu32,
109
+++ b/include/hw/i2c/allwinner-i2c.h
87
+ cpu->pmsav8r_hdregion);
110
@@ -XXX,XX +XXX,XX @@
88
+ return;
111
+/*
89
+ }
112
+ * Allwinner I2C Bus Serial Interface registers definition
90
+
113
+ *
91
+ if (cpu->pmsav8r_hdregion) {
114
+ * Copyright (C) 2022 Strahinja Jankovic. <strahinja.p.jankovic@gmail.com>
92
+ env->pmsav8.hprbar = g_new0(uint32_t,
115
+ *
93
+ cpu->pmsav8r_hdregion);
116
+ * This file is derived from IMX I2C controller,
94
+ env->pmsav8.hprlar = g_new0(uint32_t,
117
+ * by Jean-Christophe DUBOIS .
95
+ cpu->pmsav8r_hdregion);
118
+ *
96
+ }
119
+ * This program is free software; you can redistribute it and/or modify it
97
}
120
+ * under the terms of the GNU General Public License as published by the
98
121
+ * Free Software Foundation; either version 2 of the License, or
99
if (arm_feature(env, ARM_FEATURE_M_SECURITY)) {
122
+ * (at your option) any later version.
100
diff --git a/target/arm/helper.c b/target/arm/helper.c
123
+ *
101
index XXXXXXX..XXXXXXX 100644
124
+ * This program is distributed in the hope that it will be useful, but WITHOUT
102
--- a/target/arm/helper.c
125
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
103
+++ b/target/arm/helper.c
126
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
104
@@ -XXX,XX +XXX,XX @@ static void pmsav7_rgnr_write(CPUARMState *env, const ARMCPRegInfo *ri,
127
+ * for more details.
105
raw_write(env, ri, value);
128
+ *
129
+ * You should have received a copy of the GNU General Public License along
130
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
131
+ *
132
+ */
133
+
134
+#ifndef ALLWINNER_I2C_H
135
+#define ALLWINNER_I2C_H
136
+
137
+#include "hw/sysbus.h"
138
+#include "qom/object.h"
139
+
140
+#define TYPE_AW_I2C "allwinner.i2c"
141
+OBJECT_DECLARE_SIMPLE_TYPE(AWI2CState, AW_I2C)
142
+
143
+#define AW_I2C_MEM_SIZE 0x24
144
+
145
+struct AWI2CState {
146
+ /*< private >*/
147
+ SysBusDevice parent_obj;
148
+
149
+ /*< public >*/
150
+ MemoryRegion iomem;
151
+ I2CBus *bus;
152
+ qemu_irq irq;
153
+
154
+ uint8_t addr;
155
+ uint8_t xaddr;
156
+ uint8_t data;
157
+ uint8_t cntr;
158
+ uint8_t stat;
159
+ uint8_t ccr;
160
+ uint8_t srst;
161
+ uint8_t efr;
162
+ uint8_t lcr;
163
+};
164
+
165
+#endif /* ALLWINNER_I2C_H */
166
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
167
index XXXXXXX..XXXXXXX 100644
168
--- a/hw/arm/allwinner-a10.c
169
+++ b/hw/arm/allwinner-a10.c
170
@@ -XXX,XX +XXX,XX @@
171
#define AW_A10_OHCI_BASE 0x01c14400
172
#define AW_A10_SATA_BASE 0x01c18000
173
#define AW_A10_RTC_BASE 0x01c20d00
174
+#define AW_A10_I2C0_BASE 0x01c2ac00
175
176
static void aw_a10_init(Object *obj)
177
{
178
@@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj)
179
180
object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI);
181
182
+ object_initialize_child(obj, "i2c0", &s->i2c0, TYPE_AW_I2C);
183
+
184
if (machine_usb(current_machine)) {
185
int i;
186
187
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
188
/* RTC */
189
sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &error_fatal);
190
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->rtc), 0, AW_A10_RTC_BASE, 10);
191
+
192
+ /* I2C */
193
+ sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal);
194
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, AW_A10_I2C0_BASE);
195
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0, qdev_get_gpio_in(dev, 7));
106
}
196
}
107
197
108
+static void prbar_write(CPUARMState *env, const ARMCPRegInfo *ri,
198
static void aw_a10_class_init(ObjectClass *oc, void *data)
109
+ uint64_t value)
199
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
110
+{
200
index XXXXXXX..XXXXXXX 100644
111
+ ARMCPU *cpu = env_archcpu(env);
201
--- a/hw/arm/allwinner-h3.c
112
+
202
+++ b/hw/arm/allwinner-h3.c
113
+ tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
203
@@ -XXX,XX +XXX,XX @@ const hwaddr allwinner_h3_memmap[] = {
114
+ env->pmsav8.rbar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]] = value;
204
[AW_H3_DEV_UART1] = 0x01c28400,
115
+}
205
[AW_H3_DEV_UART2] = 0x01c28800,
116
+
206
[AW_H3_DEV_UART3] = 0x01c28c00,
117
+static uint64_t prbar_read(CPUARMState *env, const ARMCPRegInfo *ri)
207
+ [AW_H3_DEV_TWI0] = 0x01c2ac00,
118
+{
208
[AW_H3_DEV_EMAC] = 0x01c30000,
119
+ return env->pmsav8.rbar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]];
209
[AW_H3_DEV_DRAMCOM] = 0x01c62000,
120
+}
210
[AW_H3_DEV_DRAMCTL] = 0x01c63000,
121
+
211
@@ -XXX,XX +XXX,XX @@ struct AwH3Unimplemented {
122
+static void prlar_write(CPUARMState *env, const ARMCPRegInfo *ri,
212
{ "uart1", 0x01c28400, 1 * KiB },
123
+ uint64_t value)
213
{ "uart2", 0x01c28800, 1 * KiB },
124
+{
214
{ "uart3", 0x01c28c00, 1 * KiB },
125
+ ARMCPU *cpu = env_archcpu(env);
215
- { "twi0", 0x01c2ac00, 1 * KiB },
126
+
216
{ "twi1", 0x01c2b000, 1 * KiB },
127
+ tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
217
{ "twi2", 0x01c2b400, 1 * KiB },
128
+ env->pmsav8.rlar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]] = value;
218
{ "scr", 0x01c2c400, 1 * KiB },
129
+}
219
@@ -XXX,XX +XXX,XX @@ enum {
130
+
220
AW_H3_GIC_SPI_UART1 = 1,
131
+static uint64_t prlar_read(CPUARMState *env, const ARMCPRegInfo *ri)
221
AW_H3_GIC_SPI_UART2 = 2,
132
+{
222
AW_H3_GIC_SPI_UART3 = 3,
133
+ return env->pmsav8.rlar[M_REG_NS][env->pmsav7.rnr[M_REG_NS]];
223
+ AW_H3_GIC_SPI_TWI0 = 6,
134
+}
224
AW_H3_GIC_SPI_TIMER0 = 18,
135
+
225
AW_H3_GIC_SPI_TIMER1 = 19,
136
+static void prselr_write(CPUARMState *env, const ARMCPRegInfo *ri,
226
AW_H3_GIC_SPI_MMC0 = 60,
137
+ uint64_t value)
227
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_init(Object *obj)
138
+{
228
"ram-size");
139
+ ARMCPU *cpu = env_archcpu(env);
229
140
+
230
object_initialize_child(obj, "rtc", &s->rtc, TYPE_AW_RTC_SUN6I);
231
+
232
+ object_initialize_child(obj, "twi0", &s->i2c0, TYPE_AW_I2C);
233
}
234
235
static void allwinner_h3_realize(DeviceState *dev, Error **errp)
236
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
237
sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &error_fatal);
238
sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, s->memmap[AW_H3_DEV_RTC]);
239
240
+ /* I2C */
241
+ sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal);
242
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, s->memmap[AW_H3_DEV_TWI0]);
243
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0,
244
+ qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI0));
245
+
246
/* Unimplemented devices */
247
for (i = 0; i < ARRAY_SIZE(unimplemented); i++) {
248
create_unimplemented_device(unimplemented[i].device_name,
249
diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
250
new file mode 100644
251
index XXXXXXX..XXXXXXX
252
--- /dev/null
253
+++ b/hw/i2c/allwinner-i2c.c
254
@@ -XXX,XX +XXX,XX @@
255
+/*
256
+ * Allwinner I2C Bus Serial Interface Emulation
257
+ *
258
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
259
+ *
260
+ * This file is derived from IMX I2C controller,
261
+ * by Jean-Christophe DUBOIS .
262
+ *
263
+ * This program is free software; you can redistribute it and/or modify it
264
+ * under the terms of the GNU General Public License as published by the
265
+ * Free Software Foundation; either version 2 of the License, or
266
+ * (at your option) any later version.
267
+ *
268
+ * This program is distributed in the hope that it will be useful, but WITHOUT
269
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
270
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
271
+ * for more details.
272
+ *
273
+ * You should have received a copy of the GNU General Public License along
274
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
275
+ *
276
+ * SPDX-License-Identifier: MIT
277
+ */
278
+
279
+#include "qemu/osdep.h"
280
+#include "hw/i2c/allwinner-i2c.h"
281
+#include "hw/irq.h"
282
+#include "migration/vmstate.h"
283
+#include "hw/i2c/i2c.h"
284
+#include "qemu/log.h"
285
+#include "trace.h"
286
+#include "qemu/module.h"
287
+
288
+/* Allwinner I2C memory map */
289
+#define TWI_ADDR_REG 0x00 /* slave address register */
290
+#define TWI_XADDR_REG 0x04 /* extended slave address register */
291
+#define TWI_DATA_REG 0x08 /* data register */
292
+#define TWI_CNTR_REG 0x0c /* control register */
293
+#define TWI_STAT_REG 0x10 /* status register */
294
+#define TWI_CCR_REG 0x14 /* clock control register */
295
+#define TWI_SRST_REG 0x18 /* software reset register */
296
+#define TWI_EFR_REG 0x1c /* enhance feature register */
297
+#define TWI_LCR_REG 0x20 /* line control register */
298
+
299
+/* Used only in slave mode, do not set */
300
+#define TWI_ADDR_RESET 0
301
+#define TWI_XADDR_RESET 0
302
+
303
+/* Data register */
304
+#define TWI_DATA_MASK 0xFF
305
+#define TWI_DATA_RESET 0
306
+
307
+/* Control register */
308
+#define TWI_CNTR_INT_EN (1 << 7)
309
+#define TWI_CNTR_BUS_EN (1 << 6)
310
+#define TWI_CNTR_M_STA (1 << 5)
311
+#define TWI_CNTR_M_STP (1 << 4)
312
+#define TWI_CNTR_INT_FLAG (1 << 3)
313
+#define TWI_CNTR_A_ACK (1 << 2)
314
+#define TWI_CNTR_MASK 0xFC
315
+#define TWI_CNTR_RESET 0
316
+
317
+/* Status register */
318
+#define TWI_STAT_MASK 0xF8
319
+#define TWI_STAT_RESET 0xF8
320
+
321
+/* Clock register */
322
+#define TWI_CCR_CLK_M_MASK 0x78
323
+#define TWI_CCR_CLK_N_MASK 0x07
324
+#define TWI_CCR_MASK 0x7F
325
+#define TWI_CCR_RESET 0
326
+
327
+/* Soft reset */
328
+#define TWI_SRST_MASK 0x01
329
+#define TWI_SRST_RESET 0
330
+
331
+/* Enhance feature */
332
+#define TWI_EFR_MASK 0x03
333
+#define TWI_EFR_RESET 0
334
+
335
+/* Line control */
336
+#define TWI_LCR_SCL_STATE (1 << 5)
337
+#define TWI_LCR_SDA_STATE (1 << 4)
338
+#define TWI_LCR_SCL_CTL (1 << 3)
339
+#define TWI_LCR_SCL_CTL_EN (1 << 2)
340
+#define TWI_LCR_SDA_CTL (1 << 1)
341
+#define TWI_LCR_SDA_CTL_EN (1 << 0)
342
+#define TWI_LCR_MASK 0x3F
343
+#define TWI_LCR_RESET 0x3A
344
+
345
+/* Status value in STAT register is shifted by 3 bits */
346
+#define TWI_STAT_SHIFT 3
347
+#define STAT_FROM_STA(x) ((x) << TWI_STAT_SHIFT)
348
+#define STAT_TO_STA(x) ((x) >> TWI_STAT_SHIFT)
349
+
350
+enum {
351
+ STAT_BUS_ERROR = 0,
352
+ /* Master mode */
353
+ STAT_M_STA_TX,
354
+ STAT_M_RSTA_TX,
355
+ STAT_M_ADDR_WR_ACK,
356
+ STAT_M_ADDR_WR_NACK,
357
+ STAT_M_DATA_TX_ACK,
358
+ STAT_M_DATA_TX_NACK,
359
+ STAT_M_ARB_LOST,
360
+ STAT_M_ADDR_RD_ACK,
361
+ STAT_M_ADDR_RD_NACK,
362
+ STAT_M_DATA_RX_ACK,
363
+ STAT_M_DATA_RX_NACK,
364
+ /* Slave mode */
365
+ STAT_S_ADDR_WR_ACK,
366
+ STAT_S_ARB_LOST_AW_ACK,
367
+ STAT_S_GCA_ACK,
368
+ STAT_S_ARB_LOST_GCA_ACK,
369
+ STAT_S_DATA_RX_SA_ACK,
370
+ STAT_S_DATA_RX_SA_NACK,
371
+ STAT_S_DATA_RX_GCA_ACK,
372
+ STAT_S_DATA_RX_GCA_NACK,
373
+ STAT_S_STP_RSTA,
374
+ STAT_S_ADDR_RD_ACK,
375
+ STAT_S_ARB_LOST_AR_ACK,
376
+ STAT_S_DATA_TX_ACK,
377
+ STAT_S_DATA_TX_NACK,
378
+ STAT_S_LB_TX_ACK,
379
+ /* Master mode, 10-bit */
380
+ STAT_M_2ND_ADDR_WR_ACK,
381
+ STAT_M_2ND_ADDR_WR_NACK,
382
+ /* Idle */
383
+ STAT_IDLE = 0x1f
384
+} TWI_STAT_STA;
385
+
386
+static const char *allwinner_i2c_get_regname(unsigned offset)
387
+{
388
+ switch (offset) {
389
+ case TWI_ADDR_REG:
390
+ return "ADDR";
391
+ case TWI_XADDR_REG:
392
+ return "XADDR";
393
+ case TWI_DATA_REG:
394
+ return "DATA";
395
+ case TWI_CNTR_REG:
396
+ return "CNTR";
397
+ case TWI_STAT_REG:
398
+ return "STAT";
399
+ case TWI_CCR_REG:
400
+ return "CCR";
401
+ case TWI_SRST_REG:
402
+ return "SRST";
403
+ case TWI_EFR_REG:
404
+ return "EFR";
405
+ case TWI_LCR_REG:
406
+ return "LCR";
407
+ default:
408
+ return "[?]";
409
+ }
410
+}
411
+
412
+static inline bool allwinner_i2c_is_reset(AWI2CState *s)
413
+{
414
+ return s->srst & TWI_SRST_MASK;
415
+}
416
+
417
+static inline bool allwinner_i2c_bus_is_enabled(AWI2CState *s)
418
+{
419
+ return s->cntr & TWI_CNTR_BUS_EN;
420
+}
421
+
422
+static inline bool allwinner_i2c_interrupt_is_enabled(AWI2CState *s)
423
+{
424
+ return s->cntr & TWI_CNTR_INT_EN;
425
+}
426
+
427
+static void allwinner_i2c_reset_hold(Object *obj)
428
+{
429
+ AWI2CState *s = AW_I2C(obj);
430
+
431
+ if (STAT_TO_STA(s->stat) != STAT_IDLE) {
432
+ i2c_end_transfer(s->bus);
433
+ }
434
+
435
+ s->addr = TWI_ADDR_RESET;
436
+ s->xaddr = TWI_XADDR_RESET;
437
+ s->data = TWI_DATA_RESET;
438
+ s->cntr = TWI_CNTR_RESET;
439
+ s->stat = TWI_STAT_RESET;
440
+ s->ccr = TWI_CCR_RESET;
441
+ s->srst = TWI_SRST_RESET;
442
+ s->efr = TWI_EFR_RESET;
443
+ s->lcr = TWI_LCR_RESET;
444
+}
445
+
446
+static inline void allwinner_i2c_raise_interrupt(AWI2CState *s)
447
+{
141
+ /*
448
+ /*
142
+ * Ignore writes that would select not implemented region.
449
+ * Raise an interrupt if the device is not reset and it is configured
143
+ * This is architecturally UNPREDICTABLE.
450
+ * to generate some interrupts.
144
+ */
451
+ */
145
+ if (value >= cpu->pmsav7_dregion) {
452
+ if (!allwinner_i2c_is_reset(s) && allwinner_i2c_bus_is_enabled(s)) {
146
+ return;
453
+ if (STAT_TO_STA(s->stat) != STAT_IDLE) {
147
+ }
454
+ s->cntr |= TWI_CNTR_INT_FLAG;
148
+
455
+ if (allwinner_i2c_interrupt_is_enabled(s)) {
149
+ env->pmsav7.rnr[M_REG_NS] = value;
456
+ qemu_irq_raise(s->irq);
150
+}
457
+ }
151
+
152
+static void hprbar_write(CPUARMState *env, const ARMCPRegInfo *ri,
153
+ uint64_t value)
154
+{
155
+ ARMCPU *cpu = env_archcpu(env);
156
+
157
+ tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
158
+ env->pmsav8.hprbar[env->pmsav8.hprselr] = value;
159
+}
160
+
161
+static uint64_t hprbar_read(CPUARMState *env, const ARMCPRegInfo *ri)
162
+{
163
+ return env->pmsav8.hprbar[env->pmsav8.hprselr];
164
+}
165
+
166
+static void hprlar_write(CPUARMState *env, const ARMCPRegInfo *ri,
167
+ uint64_t value)
168
+{
169
+ ARMCPU *cpu = env_archcpu(env);
170
+
171
+ tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
172
+ env->pmsav8.hprlar[env->pmsav8.hprselr] = value;
173
+}
174
+
175
+static uint64_t hprlar_read(CPUARMState *env, const ARMCPRegInfo *ri)
176
+{
177
+ return env->pmsav8.hprlar[env->pmsav8.hprselr];
178
+}
179
+
180
+static void hprenr_write(CPUARMState *env, const ARMCPRegInfo *ri,
181
+ uint64_t value)
182
+{
183
+ uint32_t n;
184
+ uint32_t bit;
185
+ ARMCPU *cpu = env_archcpu(env);
186
+
187
+ /* Ignore writes to unimplemented regions */
188
+ int rmax = MIN(cpu->pmsav8r_hdregion, 32);
189
+ value &= MAKE_64BIT_MASK(0, rmax);
190
+
191
+ tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
192
+
193
+ /* Register alias is only valid for first 32 indexes */
194
+ for (n = 0; n < rmax; ++n) {
195
+ bit = extract32(value, n, 1);
196
+ env->pmsav8.hprlar[n] = deposit32(
197
+ env->pmsav8.hprlar[n], 0, 1, bit);
198
+ }
199
+}
200
+
201
+static uint64_t hprenr_read(CPUARMState *env, const ARMCPRegInfo *ri)
202
+{
203
+ uint32_t n;
204
+ uint32_t result = 0x0;
205
+ ARMCPU *cpu = env_archcpu(env);
206
+
207
+ /* Register alias is only valid for first 32 indexes */
208
+ for (n = 0; n < MIN(cpu->pmsav8r_hdregion, 32); ++n) {
209
+ if (env->pmsav8.hprlar[n] & 0x1) {
210
+ result |= (0x1 << n);
211
+ }
458
+ }
212
+ }
459
+ }
213
+ return result;
460
+}
214
+}
461
+
215
+
462
+static uint64_t allwinner_i2c_read(void *opaque, hwaddr offset,
216
+static void hprselr_write(CPUARMState *env, const ARMCPRegInfo *ri,
463
+ unsigned size)
217
+ uint64_t value)
464
+{
218
+{
465
+ uint16_t value;
219
+ ARMCPU *cpu = env_archcpu(env);
466
+ AWI2CState *s = AW_I2C(opaque);
220
+
467
+
221
+ /*
468
+ switch (offset) {
222
+ * Ignore writes that would select not implemented region.
469
+ case TWI_ADDR_REG:
223
+ * This is architecturally UNPREDICTABLE.
470
+ value = s->addr;
224
+ */
471
+ break;
225
+ if (value >= cpu->pmsav8r_hdregion) {
472
+ case TWI_XADDR_REG:
226
+ return;
473
+ value = s->xaddr;
474
+ break;
475
+ case TWI_DATA_REG:
476
+ if ((STAT_TO_STA(s->stat) == STAT_M_ADDR_RD_ACK) ||
477
+ (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_ACK) ||
478
+ (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_NACK)) {
479
+ /* Get the next byte */
480
+ s->data = i2c_recv(s->bus);
481
+
482
+ if (s->cntr & TWI_CNTR_A_ACK) {
483
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK);
484
+ } else {
485
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK);
486
+ }
487
+ allwinner_i2c_raise_interrupt(s);
488
+ }
489
+ value = s->data;
490
+ break;
491
+ case TWI_CNTR_REG:
492
+ value = s->cntr;
493
+ break;
494
+ case TWI_STAT_REG:
495
+ value = s->stat;
496
+ /*
497
+ * If polling when reading then change state to indicate data
498
+ * is available
499
+ */
500
+ if (STAT_TO_STA(s->stat) == STAT_M_ADDR_RD_ACK) {
501
+ if (s->cntr & TWI_CNTR_A_ACK) {
502
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK);
503
+ } else {
504
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK);
505
+ }
506
+ allwinner_i2c_raise_interrupt(s);
507
+ }
508
+ break;
509
+ case TWI_CCR_REG:
510
+ value = s->ccr;
511
+ break;
512
+ case TWI_SRST_REG:
513
+ value = s->srst;
514
+ break;
515
+ case TWI_EFR_REG:
516
+ value = s->efr;
517
+ break;
518
+ case TWI_LCR_REG:
519
+ value = s->lcr;
520
+ break;
521
+ default:
522
+ qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%"
523
+ HWADDR_PRIx "\n", TYPE_AW_I2C, __func__, offset);
524
+ value = 0;
525
+ break;
227
+ }
526
+ }
228
+
527
+
229
+ env->pmsav8.hprselr = value;
528
+ trace_allwinner_i2c_read(allwinner_i2c_get_regname(offset), offset, value);
230
+}
529
+
231
+
530
+ return (uint64_t)value;
232
+static void pmsav8r_regn_write(CPUARMState *env, const ARMCPRegInfo *ri,
531
+}
233
+ uint64_t value)
532
+
234
+{
533
+static void allwinner_i2c_write(void *opaque, hwaddr offset,
235
+ ARMCPU *cpu = env_archcpu(env);
534
+ uint64_t value, unsigned size)
236
+ uint8_t index = (extract32(ri->opc0, 0, 1) << 4) |
535
+{
237
+ (extract32(ri->crm, 0, 3) << 1) | extract32(ri->opc2, 2, 1);
536
+ AWI2CState *s = AW_I2C(opaque);
238
+
537
+
239
+ tlb_flush(CPU(cpu)); /* Mappings may have changed - purge! */
538
+ value &= 0xff;
240
+
539
+
241
+ if (ri->opc1 & 4) {
540
+ trace_allwinner_i2c_write(allwinner_i2c_get_regname(offset), offset, value);
242
+ if (index >= cpu->pmsav8r_hdregion) {
541
+
243
+ return;
542
+ switch (offset) {
543
+ case TWI_ADDR_REG:
544
+ s->addr = (uint8_t)value;
545
+ break;
546
+ case TWI_XADDR_REG:
547
+ s->xaddr = (uint8_t)value;
548
+ break;
549
+ case TWI_DATA_REG:
550
+ /* If the device is in reset or not enabled, nothing to do */
551
+ if (allwinner_i2c_is_reset(s) || (!allwinner_i2c_bus_is_enabled(s))) {
552
+ break;
244
+ }
553
+ }
245
+ if (ri->opc2 & 0x1) {
554
+
246
+ env->pmsav8.hprlar[index] = value;
555
+ s->data = value & TWI_DATA_MASK;
247
+ } else {
556
+
248
+ env->pmsav8.hprbar[index] = value;
557
+ switch (STAT_TO_STA(s->stat)) {
558
+ case STAT_M_STA_TX:
559
+ case STAT_M_RSTA_TX:
560
+ /* Send address */
561
+ if (i2c_start_transfer(s->bus, extract32(s->data, 1, 7),
562
+ extract32(s->data, 0, 1))) {
563
+ /* If non zero is returned, the address is not valid */
564
+ s->stat = STAT_FROM_STA(STAT_M_ADDR_WR_NACK);
565
+ } else {
566
+ /* Determine if read of write */
567
+ if (extract32(s->data, 0, 1)) {
568
+ s->stat = STAT_FROM_STA(STAT_M_ADDR_RD_ACK);
569
+ } else {
570
+ s->stat = STAT_FROM_STA(STAT_M_ADDR_WR_ACK);
571
+ }
572
+ allwinner_i2c_raise_interrupt(s);
573
+ }
574
+ break;
575
+ case STAT_M_ADDR_WR_ACK:
576
+ case STAT_M_DATA_TX_ACK:
577
+ if (i2c_send(s->bus, s->data)) {
578
+ /* If the target return non zero then end the transfer */
579
+ s->stat = STAT_FROM_STA(STAT_M_DATA_TX_NACK);
580
+ i2c_end_transfer(s->bus);
581
+ } else {
582
+ s->stat = STAT_FROM_STA(STAT_M_DATA_TX_ACK);
583
+ allwinner_i2c_raise_interrupt(s);
584
+ }
585
+ break;
586
+ default:
587
+ break;
249
+ }
588
+ }
250
+ } else {
589
+ break;
251
+ if (index >= cpu->pmsav7_dregion) {
590
+ case TWI_CNTR_REG:
252
+ return;
591
+ if (!allwinner_i2c_is_reset(s)) {
592
+ /* Do something only if not in software reset */
593
+ s->cntr = value & TWI_CNTR_MASK;
594
+
595
+ /* Check if start condition should be sent */
596
+ if (s->cntr & TWI_CNTR_M_STA) {
597
+ /* Update status */
598
+ if (STAT_TO_STA(s->stat) == STAT_IDLE) {
599
+ /* Send start condition */
600
+ s->stat = STAT_FROM_STA(STAT_M_STA_TX);
601
+ } else {
602
+ /* Send repeated start condition */
603
+ s->stat = STAT_FROM_STA(STAT_M_RSTA_TX);
604
+ }
605
+ /* Clear start condition */
606
+ s->cntr &= ~TWI_CNTR_M_STA;
607
+ }
608
+ if (s->cntr & TWI_CNTR_M_STP) {
609
+ /* Update status */
610
+ i2c_end_transfer(s->bus);
611
+ s->stat = STAT_FROM_STA(STAT_IDLE);
612
+ s->cntr &= ~TWI_CNTR_M_STP;
613
+ }
614
+ if ((s->cntr & TWI_CNTR_INT_FLAG) == 0) {
615
+ /* Interrupt flag cleared */
616
+ qemu_irq_lower(s->irq);
617
+ }
618
+ if ((s->cntr & TWI_CNTR_A_ACK) == 0) {
619
+ if (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_ACK) {
620
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK);
621
+ }
622
+ } else {
623
+ if (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_NACK) {
624
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK);
625
+ }
626
+ }
627
+ allwinner_i2c_raise_interrupt(s);
628
+
253
+ }
629
+ }
254
+ if (ri->opc2 & 0x1) {
630
+ break;
255
+ env->pmsav8.rlar[M_REG_NS][index] = value;
631
+ case TWI_CCR_REG:
256
+ } else {
632
+ s->ccr = value & TWI_CCR_MASK;
257
+ env->pmsav8.rbar[M_REG_NS][index] = value;
633
+ break;
634
+ case TWI_SRST_REG:
635
+ if (((value & TWI_SRST_MASK) == 0) && (s->srst & TWI_SRST_MASK)) {
636
+ /* Perform reset */
637
+ allwinner_i2c_reset_hold(OBJECT(s));
258
+ }
638
+ }
639
+ s->srst = value & TWI_SRST_MASK;
640
+ break;
641
+ case TWI_EFR_REG:
642
+ s->efr = value & TWI_EFR_MASK;
643
+ break;
644
+ case TWI_LCR_REG:
645
+ s->lcr = value & TWI_LCR_MASK;
646
+ break;
647
+ default:
648
+ qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad address at offset 0x%"
649
+ HWADDR_PRIx "\n", TYPE_AW_I2C, __func__, offset);
650
+ break;
259
+ }
651
+ }
260
+}
652
+}
261
+
653
+
262
+static uint64_t pmsav8r_regn_read(CPUARMState *env, const ARMCPRegInfo *ri)
654
+static const MemoryRegionOps allwinner_i2c_ops = {
263
+{
655
+ .read = allwinner_i2c_read,
264
+ ARMCPU *cpu = env_archcpu(env);
656
+ .write = allwinner_i2c_write,
265
+ uint8_t index = (extract32(ri->opc0, 0, 1) << 4) |
657
+ .valid.min_access_size = 1,
266
+ (extract32(ri->crm, 0, 3) << 1) | extract32(ri->opc2, 2, 1);
658
+ .valid.max_access_size = 4,
267
+
659
+ .endianness = DEVICE_NATIVE_ENDIAN,
268
+ if (ri->opc1 & 4) {
269
+ if (index >= cpu->pmsav8r_hdregion) {
270
+ return 0x0;
271
+ }
272
+ if (ri->opc2 & 0x1) {
273
+ return env->pmsav8.hprlar[index];
274
+ } else {
275
+ return env->pmsav8.hprbar[index];
276
+ }
277
+ } else {
278
+ if (index >= cpu->pmsav7_dregion) {
279
+ return 0x0;
280
+ }
281
+ if (ri->opc2 & 0x1) {
282
+ return env->pmsav8.rlar[M_REG_NS][index];
283
+ } else {
284
+ return env->pmsav8.rbar[M_REG_NS][index];
285
+ }
286
+ }
287
+}
288
+
289
+static const ARMCPRegInfo pmsav8r_cp_reginfo[] = {
290
+ { .name = "PRBAR",
291
+ .cp = 15, .opc1 = 0, .crn = 6, .crm = 3, .opc2 = 0,
292
+ .access = PL1_RW, .type = ARM_CP_NO_RAW,
293
+ .accessfn = access_tvm_trvm,
294
+ .readfn = prbar_read, .writefn = prbar_write },
295
+ { .name = "PRLAR",
296
+ .cp = 15, .opc1 = 0, .crn = 6, .crm = 3, .opc2 = 1,
297
+ .access = PL1_RW, .type = ARM_CP_NO_RAW,
298
+ .accessfn = access_tvm_trvm,
299
+ .readfn = prlar_read, .writefn = prlar_write },
300
+ { .name = "PRSELR", .resetvalue = 0,
301
+ .cp = 15, .opc1 = 0, .crn = 6, .crm = 2, .opc2 = 1,
302
+ .access = PL1_RW, .accessfn = access_tvm_trvm,
303
+ .writefn = prselr_write,
304
+ .fieldoffset = offsetof(CPUARMState, pmsav7.rnr[M_REG_NS]) },
305
+ { .name = "HPRBAR", .resetvalue = 0,
306
+ .cp = 15, .opc1 = 4, .crn = 6, .crm = 3, .opc2 = 0,
307
+ .access = PL2_RW, .type = ARM_CP_NO_RAW,
308
+ .readfn = hprbar_read, .writefn = hprbar_write },
309
+ { .name = "HPRLAR",
310
+ .cp = 15, .opc1 = 4, .crn = 6, .crm = 3, .opc2 = 1,
311
+ .access = PL2_RW, .type = ARM_CP_NO_RAW,
312
+ .readfn = hprlar_read, .writefn = hprlar_write },
313
+ { .name = "HPRSELR", .resetvalue = 0,
314
+ .cp = 15, .opc1 = 4, .crn = 6, .crm = 2, .opc2 = 1,
315
+ .access = PL2_RW,
316
+ .writefn = hprselr_write,
317
+ .fieldoffset = offsetof(CPUARMState, pmsav8.hprselr) },
318
+ { .name = "HPRENR",
319
+ .cp = 15, .opc1 = 4, .crn = 6, .crm = 1, .opc2 = 1,
320
+ .access = PL2_RW, .type = ARM_CP_NO_RAW,
321
+ .readfn = hprenr_read, .writefn = hprenr_write },
322
+};
660
+};
323
+
661
+
324
static const ARMCPRegInfo pmsav7_cp_reginfo[] = {
662
+static const VMStateDescription allwinner_i2c_vmstate = {
325
/* Reset for all these registers is handled in arm_cpu_reset(),
663
+ .name = TYPE_AW_I2C,
326
* because the PMSAv7 is also used by M-profile CPUs, which do
327
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
328
.access = PL1_R, .type = ARM_CP_CONST,
329
.resetvalue = cpu->pmsav7_dregion << 8
330
};
331
+ /* HMPUIR is specific to PMSA V8 */
332
+ ARMCPRegInfo id_hmpuir_reginfo = {
333
+ .name = "HMPUIR",
334
+ .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 4,
335
+ .access = PL2_R, .type = ARM_CP_CONST,
336
+ .resetvalue = cpu->pmsav8r_hdregion
337
+ };
338
static const ARMCPRegInfo crn0_wi_reginfo = {
339
.name = "CRN0_WI", .cp = 15, .crn = 0, .crm = CP_ANY,
340
.opc1 = CP_ANY, .opc2 = CP_ANY, .access = PL1_W,
341
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
342
define_arm_cp_regs(cpu, id_cp_reginfo);
343
if (!arm_feature(env, ARM_FEATURE_PMSA)) {
344
define_one_arm_cp_reg(cpu, &id_tlbtr_reginfo);
345
+ } else if (arm_feature(env, ARM_FEATURE_PMSA) &&
346
+ arm_feature(env, ARM_FEATURE_V8)) {
347
+ uint32_t i = 0;
348
+ char *tmp_string;
349
+
350
+ define_one_arm_cp_reg(cpu, &id_mpuir_reginfo);
351
+ define_one_arm_cp_reg(cpu, &id_hmpuir_reginfo);
352
+ define_arm_cp_regs(cpu, pmsav8r_cp_reginfo);
353
+
354
+ /* Register alias is only valid for first 32 indexes */
355
+ for (i = 0; i < MIN(cpu->pmsav7_dregion, 32); ++i) {
356
+ uint8_t crm = 0b1000 | extract32(i, 1, 3);
357
+ uint8_t opc1 = extract32(i, 4, 1);
358
+ uint8_t opc2 = extract32(i, 0, 1) << 2;
359
+
360
+ tmp_string = g_strdup_printf("PRBAR%u", i);
361
+ ARMCPRegInfo tmp_prbarn_reginfo = {
362
+ .name = tmp_string, .type = ARM_CP_ALIAS | ARM_CP_NO_RAW,
363
+ .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2,
364
+ .access = PL1_RW, .resetvalue = 0,
365
+ .accessfn = access_tvm_trvm,
366
+ .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read
367
+ };
368
+ define_one_arm_cp_reg(cpu, &tmp_prbarn_reginfo);
369
+ g_free(tmp_string);
370
+
371
+ opc2 = extract32(i, 0, 1) << 2 | 0x1;
372
+ tmp_string = g_strdup_printf("PRLAR%u", i);
373
+ ARMCPRegInfo tmp_prlarn_reginfo = {
374
+ .name = tmp_string, .type = ARM_CP_ALIAS | ARM_CP_NO_RAW,
375
+ .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2,
376
+ .access = PL1_RW, .resetvalue = 0,
377
+ .accessfn = access_tvm_trvm,
378
+ .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read
379
+ };
380
+ define_one_arm_cp_reg(cpu, &tmp_prlarn_reginfo);
381
+ g_free(tmp_string);
382
+ }
383
+
384
+ /* Register alias is only valid for first 32 indexes */
385
+ for (i = 0; i < MIN(cpu->pmsav8r_hdregion, 32); ++i) {
386
+ uint8_t crm = 0b1000 | extract32(i, 1, 3);
387
+ uint8_t opc1 = 0b100 | extract32(i, 4, 1);
388
+ uint8_t opc2 = extract32(i, 0, 1) << 2;
389
+
390
+ tmp_string = g_strdup_printf("HPRBAR%u", i);
391
+ ARMCPRegInfo tmp_hprbarn_reginfo = {
392
+ .name = tmp_string,
393
+ .type = ARM_CP_NO_RAW,
394
+ .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2,
395
+ .access = PL2_RW, .resetvalue = 0,
396
+ .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read
397
+ };
398
+ define_one_arm_cp_reg(cpu, &tmp_hprbarn_reginfo);
399
+ g_free(tmp_string);
400
+
401
+ opc2 = extract32(i, 0, 1) << 2 | 0x1;
402
+ tmp_string = g_strdup_printf("HPRLAR%u", i);
403
+ ARMCPRegInfo tmp_hprlarn_reginfo = {
404
+ .name = tmp_string,
405
+ .type = ARM_CP_NO_RAW,
406
+ .cp = 15, .opc1 = opc1, .crn = 6, .crm = crm, .opc2 = opc2,
407
+ .access = PL2_RW, .resetvalue = 0,
408
+ .writefn = pmsav8r_regn_write, .readfn = pmsav8r_regn_read
409
+ };
410
+ define_one_arm_cp_reg(cpu, &tmp_hprlarn_reginfo);
411
+ g_free(tmp_string);
412
+ }
413
} else if (arm_feature(env, ARM_FEATURE_V7)) {
414
define_one_arm_cp_reg(cpu, &id_mpuir_reginfo);
415
}
416
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
417
sctlr.type |= ARM_CP_SUPPRESS_TB_END;
418
}
419
define_one_arm_cp_reg(cpu, &sctlr);
420
+
421
+ if (arm_feature(env, ARM_FEATURE_PMSA) &&
422
+ arm_feature(env, ARM_FEATURE_V8)) {
423
+ ARMCPRegInfo vsctlr = {
424
+ .name = "VSCTLR", .state = ARM_CP_STATE_AA32,
425
+ .cp = 15, .opc1 = 4, .crn = 2, .crm = 0, .opc2 = 0,
426
+ .access = PL2_RW, .resetvalue = 0x0,
427
+ .fieldoffset = offsetoflow32(CPUARMState, cp15.vsctlr),
428
+ };
429
+ define_one_arm_cp_reg(cpu, &vsctlr);
430
+ }
431
}
432
433
if (cpu_isar_feature(aa64_lor, cpu)) {
434
diff --git a/target/arm/machine.c b/target/arm/machine.c
435
index XXXXXXX..XXXXXXX 100644
436
--- a/target/arm/machine.c
437
+++ b/target/arm/machine.c
438
@@ -XXX,XX +XXX,XX @@ static bool pmsav8_needed(void *opaque)
439
arm_feature(env, ARM_FEATURE_V8);
440
}
441
442
+static bool pmsav8r_needed(void *opaque)
443
+{
444
+ ARMCPU *cpu = opaque;
445
+ CPUARMState *env = &cpu->env;
446
+
447
+ return arm_feature(env, ARM_FEATURE_PMSA) &&
448
+ arm_feature(env, ARM_FEATURE_V8) &&
449
+ !arm_feature(env, ARM_FEATURE_M);
450
+}
451
+
452
+static const VMStateDescription vmstate_pmsav8r = {
453
+ .name = "cpu/pmsav8/pmsav8r",
454
+ .version_id = 1,
664
+ .version_id = 1,
455
+ .minimum_version_id = 1,
665
+ .minimum_version_id = 1,
456
+ .needed = pmsav8r_needed,
457
+ .fields = (VMStateField[]) {
666
+ .fields = (VMStateField[]) {
458
+ VMSTATE_VARRAY_UINT32(env.pmsav8.hprbar, ARMCPU,
667
+ VMSTATE_UINT8(addr, AWI2CState),
459
+ pmsav8r_hdregion, 0, vmstate_info_uint32, uint32_t),
668
+ VMSTATE_UINT8(xaddr, AWI2CState),
460
+ VMSTATE_VARRAY_UINT32(env.pmsav8.hprlar, ARMCPU,
669
+ VMSTATE_UINT8(data, AWI2CState),
461
+ pmsav8r_hdregion, 0, vmstate_info_uint32, uint32_t),
670
+ VMSTATE_UINT8(cntr, AWI2CState),
671
+ VMSTATE_UINT8(ccr, AWI2CState),
672
+ VMSTATE_UINT8(srst, AWI2CState),
673
+ VMSTATE_UINT8(efr, AWI2CState),
674
+ VMSTATE_UINT8(lcr, AWI2CState),
462
+ VMSTATE_END_OF_LIST()
675
+ VMSTATE_END_OF_LIST()
463
+ },
676
+ }
464
+};
677
+};
465
+
678
+
466
static const VMStateDescription vmstate_pmsav8 = {
679
+static void allwinner_i2c_realize(DeviceState *dev, Error **errp)
467
.name = "cpu/pmsav8",
680
+{
468
.version_id = 1,
681
+ AWI2CState *s = AW_I2C(dev);
469
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pmsav8 = {
682
+
470
VMSTATE_UINT32(env.pmsav8.mair0[M_REG_NS], ARMCPU),
683
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_i2c_ops, s,
471
VMSTATE_UINT32(env.pmsav8.mair1[M_REG_NS], ARMCPU),
684
+ TYPE_AW_I2C, AW_I2C_MEM_SIZE);
472
VMSTATE_END_OF_LIST()
685
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
473
+ },
686
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
474
+ .subsections = (const VMStateDescription * []) {
687
+ s->bus = i2c_init_bus(dev, "i2c");
475
+ &vmstate_pmsav8r,
688
+}
476
+ NULL
689
+
477
}
690
+static void allwinner_i2c_class_init(ObjectClass *klass, void *data)
478
};
691
+{
479
692
+ DeviceClass *dc = DEVICE_CLASS(klass);
693
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
694
+
695
+ rc->phases.hold = allwinner_i2c_reset_hold;
696
+ dc->vmsd = &allwinner_i2c_vmstate;
697
+ dc->realize = allwinner_i2c_realize;
698
+ dc->desc = "Allwinner I2C Controller";
699
+}
700
+
701
+static const TypeInfo allwinner_i2c_type_info = {
702
+ .name = TYPE_AW_I2C,
703
+ .parent = TYPE_SYS_BUS_DEVICE,
704
+ .instance_size = sizeof(AWI2CState),
705
+ .class_init = allwinner_i2c_class_init,
706
+};
707
+
708
+static void allwinner_i2c_register_types(void)
709
+{
710
+ type_register_static(&allwinner_i2c_type_info);
711
+}
712
+
713
+type_init(allwinner_i2c_register_types)
714
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
715
index XXXXXXX..XXXXXXX 100644
716
--- a/hw/arm/Kconfig
717
+++ b/hw/arm/Kconfig
718
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
719
select ALLWINNER_A10_CCM
720
select ALLWINNER_A10_DRAMC
721
select ALLWINNER_EMAC
722
+ select ALLWINNER_I2C
723
select SERIAL
724
select UNIMP
725
726
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_H3
727
bool
728
select ALLWINNER_A10_PIT
729
select ALLWINNER_SUN8I_EMAC
730
+ select ALLWINNER_I2C
731
select SERIAL
732
select ARM_TIMER
733
select ARM_GIC
734
diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig
735
index XXXXXXX..XXXXXXX 100644
736
--- a/hw/i2c/Kconfig
737
+++ b/hw/i2c/Kconfig
738
@@ -XXX,XX +XXX,XX @@ config MPC_I2C
739
bool
740
select I2C
741
742
+config ALLWINNER_I2C
743
+ bool
744
+ select I2C
745
+
746
config PCA954X
747
bool
748
select I2C
749
diff --git a/hw/i2c/meson.build b/hw/i2c/meson.build
750
index XXXXXXX..XXXXXXX 100644
751
--- a/hw/i2c/meson.build
752
+++ b/hw/i2c/meson.build
753
@@ -XXX,XX +XXX,XX @@ i2c_ss.add(when: 'CONFIG_BITBANG_I2C', if_true: files('bitbang_i2c.c'))
754
i2c_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_i2c.c'))
755
i2c_ss.add(when: 'CONFIG_IMX_I2C', if_true: files('imx_i2c.c'))
756
i2c_ss.add(when: 'CONFIG_MPC_I2C', if_true: files('mpc_i2c.c'))
757
+i2c_ss.add(when: 'CONFIG_ALLWINNER_I2C', if_true: files('allwinner-i2c.c'))
758
i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c'))
759
i2c_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_smbus.c'))
760
i2c_ss.add(when: 'CONFIG_SMBUS_EEPROM', if_true: files('smbus_eeprom.c'))
761
diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events
762
index XXXXXXX..XXXXXXX 100644
763
--- a/hw/i2c/trace-events
764
+++ b/hw/i2c/trace-events
765
@@ -XXX,XX +XXX,XX @@ i2c_send_async(uint8_t address, uint8_t data) "send_async(addr:0x%02x) data:0x%0
766
i2c_recv(uint8_t address, uint8_t data) "recv(addr:0x%02x) data:0x%02x"
767
i2c_ack(void) ""
768
769
+# allwinner_i2c.c
770
+
771
+allwinner_i2c_read(const char* reg_name, uint64_t offset, uint64_t value) "read %s [0x%" PRIx64 "]: -> 0x%" PRIx64
772
+allwinner_i2c_write(const char* reg_name, uint64_t offset, uint64_t value) "write %s [0x%" PRIx64 "]: <- 0x%" PRIx64
773
+
774
# aspeed_i2c.c
775
776
aspeed_i2c_bus_cmd(uint32_t cmd, const char *cmd_flags, uint32_t count, uint32_t intr_status) "handling cmd=0x%x %s count=%d intr=0x%x"
480
--
777
--
481
2.25.1
778
2.34.1
482
483
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
remove unused defines, add needed defines
3
This patch adds minimal support for AXP-209 PMU.
4
Most important is chip ID since U-Boot SPL expects version 0x1. Besides
5
the chip ID register, reset values for two more registers used by A10
6
U-Boot SPL are covered.
4
7
5
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
8
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
9
Message-id: 20221226220303.14420-5-strahinja.p.jankovic@gmail.com
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
12
---
9
include/hw/timer/imx_epit.h | 4 ++--
13
hw/misc/axp209.c | 238 +++++++++++++++++++++++++++++++++++++++++++
10
hw/timer/imx_epit.c | 4 ++--
14
MAINTAINERS | 2 +
11
2 files changed, 4 insertions(+), 4 deletions(-)
15
hw/misc/Kconfig | 4 +
16
hw/misc/meson.build | 1 +
17
hw/misc/trace-events | 5 +
18
5 files changed, 250 insertions(+)
19
create mode 100644 hw/misc/axp209.c
12
20
13
diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h
21
diff --git a/hw/misc/axp209.c b/hw/misc/axp209.c
22
new file mode 100644
23
index XXXXXXX..XXXXXXX
24
--- /dev/null
25
+++ b/hw/misc/axp209.c
26
@@ -XXX,XX +XXX,XX @@
27
+/*
28
+ * AXP-209 PMU Emulation
29
+ *
30
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
31
+ *
32
+ * Permission is hereby granted, free of charge, to any person obtaining a
33
+ * copy of this software and associated documentation files (the "Software"),
34
+ * to deal in the Software without restriction, including without limitation
35
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
36
+ * and/or sell copies of the Software, and to permit persons to whom the
37
+ * Software is furnished to do so, subject to the following conditions:
38
+ *
39
+ * The above copyright notice and this permission notice shall be included in
40
+ * all copies or substantial portions of the Software.
41
+ *
42
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
47
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
48
+ * DEALINGS IN THE SOFTWARE.
49
+ *
50
+ * SPDX-License-Identifier: MIT
51
+ */
52
+
53
+#include "qemu/osdep.h"
54
+#include "qemu/log.h"
55
+#include "trace.h"
56
+#include "hw/i2c/i2c.h"
57
+#include "migration/vmstate.h"
58
+
59
+#define TYPE_AXP209_PMU "axp209_pmu"
60
+
61
+#define AXP209(obj) \
62
+ OBJECT_CHECK(AXP209I2CState, (obj), TYPE_AXP209_PMU)
63
+
64
+/* registers */
65
+enum {
66
+ REG_POWER_STATUS = 0x0u,
67
+ REG_OPERATING_MODE,
68
+ REG_OTG_VBUS_STATUS,
69
+ REG_CHIP_VERSION,
70
+ REG_DATA_CACHE_0,
71
+ REG_DATA_CACHE_1,
72
+ REG_DATA_CACHE_2,
73
+ REG_DATA_CACHE_3,
74
+ REG_DATA_CACHE_4,
75
+ REG_DATA_CACHE_5,
76
+ REG_DATA_CACHE_6,
77
+ REG_DATA_CACHE_7,
78
+ REG_DATA_CACHE_8,
79
+ REG_DATA_CACHE_9,
80
+ REG_DATA_CACHE_A,
81
+ REG_DATA_CACHE_B,
82
+ REG_POWER_OUTPUT_CTRL = 0x12u,
83
+ REG_DC_DC2_OUT_V_CTRL = 0x23u,
84
+ REG_DC_DC2_DVS_CTRL = 0x25u,
85
+ REG_DC_DC3_OUT_V_CTRL = 0x27u,
86
+ REG_LDO2_4_OUT_V_CTRL,
87
+ REG_LDO3_OUT_V_CTRL,
88
+ REG_VBUS_CH_MGMT = 0x30u,
89
+ REG_SHUTDOWN_V_CTRL,
90
+ REG_SHUTDOWN_CTRL,
91
+ REG_CHARGE_CTRL_1,
92
+ REG_CHARGE_CTRL_2,
93
+ REG_SPARE_CHARGE_CTRL,
94
+ REG_PEK_KEY_CTRL,
95
+ REG_DC_DC_FREQ_SET,
96
+ REG_CHR_TEMP_TH_SET,
97
+ REG_CHR_HIGH_TEMP_TH_CTRL,
98
+ REG_IPSOUT_WARN_L1,
99
+ REG_IPSOUT_WARN_L2,
100
+ REG_DISCHR_TEMP_TH_SET,
101
+ REG_DISCHR_HIGH_TEMP_TH_CTRL,
102
+ REG_IRQ_BANK_1_CTRL = 0x40u,
103
+ REG_IRQ_BANK_2_CTRL,
104
+ REG_IRQ_BANK_3_CTRL,
105
+ REG_IRQ_BANK_4_CTRL,
106
+ REG_IRQ_BANK_5_CTRL,
107
+ REG_IRQ_BANK_1_STAT = 0x48u,
108
+ REG_IRQ_BANK_2_STAT,
109
+ REG_IRQ_BANK_3_STAT,
110
+ REG_IRQ_BANK_4_STAT,
111
+ REG_IRQ_BANK_5_STAT,
112
+ REG_ADC_ACIN_V_H = 0x56u,
113
+ REG_ADC_ACIN_V_L,
114
+ REG_ADC_ACIN_CURR_H,
115
+ REG_ADC_ACIN_CURR_L,
116
+ REG_ADC_VBUS_V_H,
117
+ REG_ADC_VBUS_V_L,
118
+ REG_ADC_VBUS_CURR_H,
119
+ REG_ADC_VBUS_CURR_L,
120
+ REG_ADC_INT_TEMP_H,
121
+ REG_ADC_INT_TEMP_L,
122
+ REG_ADC_TEMP_SENS_V_H = 0x62u,
123
+ REG_ADC_TEMP_SENS_V_L,
124
+ REG_ADC_BAT_V_H = 0x78u,
125
+ REG_ADC_BAT_V_L,
126
+ REG_ADC_BAT_DISCHR_CURR_H,
127
+ REG_ADC_BAT_DISCHR_CURR_L,
128
+ REG_ADC_BAT_CHR_CURR_H,
129
+ REG_ADC_BAT_CHR_CURR_L,
130
+ REG_ADC_IPSOUT_V_H,
131
+ REG_ADC_IPSOUT_V_L,
132
+ REG_DC_DC_MOD_SEL = 0x80u,
133
+ REG_ADC_EN_1,
134
+ REG_ADC_EN_2,
135
+ REG_ADC_SR_CTRL,
136
+ REG_ADC_IN_RANGE,
137
+ REG_GPIO1_ADC_IRQ_RISING_TH,
138
+ REG_GPIO1_ADC_IRQ_FALLING_TH,
139
+ REG_TIMER_CTRL = 0x8au,
140
+ REG_VBUS_CTRL_MON_SRP,
141
+ REG_OVER_TEMP_SHUTDOWN = 0x8fu,
142
+ REG_GPIO0_FEAT_SET,
143
+ REG_GPIO_OUT_HIGH_SET,
144
+ REG_GPIO1_FEAT_SET,
145
+ REG_GPIO2_FEAT_SET,
146
+ REG_GPIO_SIG_STATE_SET_MON,
147
+ REG_GPIO3_SET,
148
+ REG_COULOMB_CNTR_CTRL = 0xb8u,
149
+ REG_POWER_MEAS_RES,
150
+ NR_REGS
151
+};
152
+
153
+#define AXP209_CHIP_VERSION_ID (0x01)
154
+#define AXP209_DC_DC2_OUT_V_CTRL_RESET (0x16)
155
+#define AXP209_IRQ_BANK_1_CTRL_RESET (0xd8)
156
+
157
+/* A simple I2C slave which returns values of ID or CNT register. */
158
+typedef struct AXP209I2CState {
159
+ /*< private >*/
160
+ I2CSlave i2c;
161
+ /*< public >*/
162
+ uint8_t regs[NR_REGS]; /* peripheral registers */
163
+ uint8_t ptr; /* current register index */
164
+ uint8_t count; /* counter used for tx/rx */
165
+} AXP209I2CState;
166
+
167
+/* Reset all counters and load ID register */
168
+static void axp209_reset_enter(Object *obj, ResetType type)
169
+{
170
+ AXP209I2CState *s = AXP209(obj);
171
+
172
+ memset(s->regs, 0, NR_REGS);
173
+ s->ptr = 0;
174
+ s->count = 0;
175
+ s->regs[REG_CHIP_VERSION] = AXP209_CHIP_VERSION_ID;
176
+ s->regs[REG_DC_DC2_OUT_V_CTRL] = AXP209_DC_DC2_OUT_V_CTRL_RESET;
177
+ s->regs[REG_IRQ_BANK_1_CTRL] = AXP209_IRQ_BANK_1_CTRL_RESET;
178
+}
179
+
180
+/* Handle events from master. */
181
+static int axp209_event(I2CSlave *i2c, enum i2c_event event)
182
+{
183
+ AXP209I2CState *s = AXP209(i2c);
184
+
185
+ s->count = 0;
186
+
187
+ return 0;
188
+}
189
+
190
+/* Called when master requests read */
191
+static uint8_t axp209_rx(I2CSlave *i2c)
192
+{
193
+ AXP209I2CState *s = AXP209(i2c);
194
+ uint8_t ret = 0xff;
195
+
196
+ if (s->ptr < NR_REGS) {
197
+ ret = s->regs[s->ptr++];
198
+ }
199
+
200
+ trace_axp209_rx(s->ptr - 1, ret);
201
+
202
+ return ret;
203
+}
204
+
205
+/*
206
+ * Called when master sends write.
207
+ * Update ptr with byte 0, then perform write with second byte.
208
+ */
209
+static int axp209_tx(I2CSlave *i2c, uint8_t data)
210
+{
211
+ AXP209I2CState *s = AXP209(i2c);
212
+
213
+ if (s->count == 0) {
214
+ /* Store register address */
215
+ s->ptr = data;
216
+ s->count++;
217
+ trace_axp209_select(data);
218
+ } else {
219
+ trace_axp209_tx(s->ptr, data);
220
+ if (s->ptr == REG_DC_DC2_OUT_V_CTRL) {
221
+ s->regs[s->ptr++] = data;
222
+ }
223
+ }
224
+
225
+ return 0;
226
+}
227
+
228
+static const VMStateDescription vmstate_axp209 = {
229
+ .name = TYPE_AXP209_PMU,
230
+ .version_id = 1,
231
+ .fields = (VMStateField[]) {
232
+ VMSTATE_UINT8_ARRAY(regs, AXP209I2CState, NR_REGS),
233
+ VMSTATE_UINT8(count, AXP209I2CState),
234
+ VMSTATE_UINT8(ptr, AXP209I2CState),
235
+ VMSTATE_END_OF_LIST()
236
+ }
237
+};
238
+
239
+static void axp209_class_init(ObjectClass *oc, void *data)
240
+{
241
+ DeviceClass *dc = DEVICE_CLASS(oc);
242
+ I2CSlaveClass *isc = I2C_SLAVE_CLASS(oc);
243
+ ResettableClass *rc = RESETTABLE_CLASS(oc);
244
+
245
+ rc->phases.enter = axp209_reset_enter;
246
+ dc->vmsd = &vmstate_axp209;
247
+ isc->event = axp209_event;
248
+ isc->recv = axp209_rx;
249
+ isc->send = axp209_tx;
250
+}
251
+
252
+static const TypeInfo axp209_info = {
253
+ .name = TYPE_AXP209_PMU,
254
+ .parent = TYPE_I2C_SLAVE,
255
+ .instance_size = sizeof(AXP209I2CState),
256
+ .class_init = axp209_class_init
257
+};
258
+
259
+static void axp209_register_devices(void)
260
+{
261
+ type_register_static(&axp209_info);
262
+}
263
+
264
+type_init(axp209_register_devices);
265
diff --git a/MAINTAINERS b/MAINTAINERS
14
index XXXXXXX..XXXXXXX 100644
266
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/timer/imx_epit.h
267
--- a/MAINTAINERS
16
+++ b/include/hw/timer/imx_epit.h
268
+++ b/MAINTAINERS
17
@@ -XXX,XX +XXX,XX @@
269
@@ -XXX,XX +XXX,XX @@ ARM Machines
18
#define CR_OCIEN (1 << 2)
270
Allwinner-a10
19
#define CR_RLD (1 << 3)
271
M: Beniamino Galvani <b.galvani@gmail.com>
20
#define CR_PRESCALE_SHIFT (4)
272
M: Peter Maydell <peter.maydell@linaro.org>
21
-#define CR_PRESCALE_MASK (0xfff)
273
+R: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
22
+#define CR_PRESCALE_BITS (12)
274
L: qemu-arm@nongnu.org
23
#define CR_SWR (1 << 16)
275
S: Odd Fixes
24
#define CR_IOVW (1 << 17)
276
F: hw/*/allwinner*
25
#define CR_DBGEN (1 << 18)
277
F: include/hw/*/allwinner*
26
@@ -XXX,XX +XXX,XX @@
278
F: hw/arm/cubieboard.c
27
#define CR_DOZEN (1 << 20)
279
F: docs/system/arm/cubieboard.rst
28
#define CR_STOPEN (1 << 21)
280
+F: hw/misc/axp209.c
29
#define CR_CLKSRC_SHIFT (24)
281
30
-#define CR_CLKSRC_MASK (0x3 << CR_CLKSRC_SHIFT)
282
Allwinner-h3
31
+#define CR_CLKSRC_BITS (2)
283
M: Niek Linnenbank <nieklinnenbank@gmail.com>
32
284
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
33
#define EPIT_TIMER_MAX 0XFFFFFFFFUL
34
35
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
36
index XXXXXXX..XXXXXXX 100644
285
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/timer/imx_epit.c
286
--- a/hw/misc/Kconfig
38
+++ b/hw/timer/imx_epit.c
287
+++ b/hw/misc/Kconfig
39
@@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s)
288
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10_CCM
40
uint32_t clksrc;
289
config ALLWINNER_A10_DRAMC
41
uint32_t prescaler;
290
bool
42
291
43
- clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, 2);
292
+config AXP209_PMU
44
- prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, 12);
293
+ bool
45
+ clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, CR_CLKSRC_BITS);
294
+ depends on I2C
46
+ prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, CR_PRESCALE_BITS);
295
+
47
296
source macio/Kconfig
48
s->freq = imx_ccm_get_clock_frequency(s->ccm,
297
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
49
imx_epit_clocks[clksrc]) / prescaler;
298
index XXXXXXX..XXXXXXX 100644
299
--- a/hw/misc/meson.build
300
+++ b/hw/misc/meson.build
301
@@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'
302
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
303
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-sysctrl.c'))
304
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sid.c'))
305
+softmmu_ss.add(when: 'CONFIG_AXP209_PMU', if_true: files('axp209.c'))
306
softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('arm_sysctl.c'))
307
softmmu_ss.add(when: 'CONFIG_NSERIES', if_true: files('cbus.c'))
308
softmmu_ss.add(when: 'CONFIG_ECCMEMCTL', if_true: files('eccmemctl.c'))
309
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
310
index XXXXXXX..XXXXXXX 100644
311
--- a/hw/misc/trace-events
312
+++ b/hw/misc/trace-events
313
@@ -XXX,XX +XXX,XX @@ allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%"
314
avr_power_read(uint8_t value) "power_reduc read value:%u"
315
avr_power_write(uint8_t value) "power_reduc write value:%u"
316
317
+# axp209.c
318
+axp209_rx(uint8_t reg, uint8_t data) "Read reg 0x%" PRIx8 " : 0x%" PRIx8
319
+axp209_select(uint8_t reg) "Accessing reg 0x%" PRIx8
320
+axp209_tx(uint8_t reg, uint8_t data) "Write reg 0x%" PRIx8 " : 0x%" PRIx8
321
+
322
# eccmemctl.c
323
ecc_mem_writel_mer(uint32_t val) "Write memory enable 0x%08x"
324
ecc_mem_writel_mdr(uint32_t val) "Write memory delay 0x%08x"
50
--
325
--
51
2.25.1
326
2.34.1
diff view generated by jsdifflib
1
In get_phys_addr_twostage() we set the lg_page_size of the result to
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
the maximum of the stage 1 and stage 2 page sizes. This works for
3
the case where we do want to create a TLB entry, because we know the
4
common TLB code only creates entries of the TARGET_PAGE_SIZE and
5
asking for a size larger than that only means that invalidations
6
invalidate the whole larger area. However, if lg_page_size is
7
smaller than TARGET_PAGE_SIZE this effectively means "don't create a
8
TLB entry"; in this case if either S1 or S2 said "this covers less
9
than a page and can't go in a TLB" then the final result also should
10
be marked that way. Set the resulting page size to 0 if either
11
stage asked for a less-than-a-page entry, and expand the comment
12
to explain what's going on.
13
2
14
This has no effect for VMSA because currently the VMSA lookup always
3
SPL Boot for Cubieboard expects AXP209 connected to I2C0 bus.
15
returns results that cover at least TARGET_PAGE_SIZE; however when we
16
add v8R support it will reuse this code path, and for v8R the S1 and
17
S2 results can be smaller than TARGET_PAGE_SIZE.
18
4
5
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
6
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20221226220303.14420-6-strahinja.p.jankovic@gmail.com
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Message-id: 20221212142708.610090-1-peter.maydell@linaro.org
22
---
10
---
23
target/arm/ptw.c | 16 +++++++++++++---
11
hw/arm/cubieboard.c | 6 ++++++
24
1 file changed, 13 insertions(+), 3 deletions(-)
12
hw/arm/Kconfig | 1 +
13
2 files changed, 7 insertions(+)
25
14
26
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
15
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
27
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
28
--- a/target/arm/ptw.c
17
--- a/hw/arm/cubieboard.c
29
+++ b/target/arm/ptw.c
18
+++ b/hw/arm/cubieboard.c
30
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
19
@@ -XXX,XX +XXX,XX @@
20
#include "hw/boards.h"
21
#include "hw/qdev-properties.h"
22
#include "hw/arm/allwinner-a10.h"
23
+#include "hw/i2c/i2c.h"
24
25
static struct arm_boot_info cubieboard_binfo = {
26
.loader_start = AW_A10_SDRAM_BASE,
27
@@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine)
28
BlockBackend *blk;
29
BusState *bus;
30
DeviceState *carddev;
31
+ I2CBus *i2c;
32
33
/* BIOS is not supported by this board */
34
if (machine->firmware) {
35
@@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine)
36
exit(1);
31
}
37
}
32
38
33
/*
39
+ /* Connect AXP 209 */
34
- * Use the maximum of the S1 & S2 page size, so that invalidation
40
+ i2c = I2C_BUS(qdev_get_child_bus(DEVICE(&a10->i2c0), "i2c"));
35
- * of pages > TARGET_PAGE_SIZE works correctly.
41
+ i2c_slave_create_simple(i2c, "axp209_pmu", 0x34);
36
+ * If either S1 or S2 returned a result smaller than TARGET_PAGE_SIZE,
42
+
37
+ * this means "don't put this in the TLB"; in this case, return a
43
/* Retrieve SD bus */
38
+ * result with lg_page_size == 0 to achieve that. Otherwise,
44
di = drive_get(IF_SD, 0, 0);
39
+ * use the maximum of the S1 & S2 page size, so that invalidation
45
blk = di ? blk_by_legacy_dinfo(di) : NULL;
40
+ * of pages > TARGET_PAGE_SIZE works correctly. (This works even though
46
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
41
+ * we know the combined result permissions etc only cover the minimum
47
index XXXXXXX..XXXXXXX 100644
42
+ * of the S1 and S2 page size, because we know that the common TLB code
48
--- a/hw/arm/Kconfig
43
+ * never actually creates TLB entries bigger than TARGET_PAGE_SIZE,
49
+++ b/hw/arm/Kconfig
44
+ * and passing a larger page size value only affects invalidations.)
50
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
45
*/
51
select ALLWINNER_A10_DRAMC
46
- if (result->f.lg_page_size < s1_lgpgsz) {
52
select ALLWINNER_EMAC
47
+ if (result->f.lg_page_size < TARGET_PAGE_BITS ||
53
select ALLWINNER_I2C
48
+ s1_lgpgsz < TARGET_PAGE_BITS) {
54
+ select AXP209_PMU
49
+ result->f.lg_page_size = 0;
55
select SERIAL
50
+ } else if (result->f.lg_page_size < s1_lgpgsz) {
56
select UNIMP
51
result->f.lg_page_size = s1_lgpgsz;
52
}
53
57
54
--
58
--
55
2.25.1
59
2.34.1
60
61
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
3
This patch enables copying of SPL from MMC if `-kernel` parameter is not
4
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
4
passed when starting QEMU. SPL is copied to SRAM_A.
5
6
The approach is reused from Allwinner H3 implementation.
7
8
Tested with Armbian and custom Yocto image.
9
10
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
11
12
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
13
Message-id: 20221226220303.14420-7-strahinja.p.jankovic@gmail.com
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
---
15
---
7
hw/timer/imx_epit.c | 20 ++++++++++++++------
16
include/hw/arm/allwinner-a10.h | 21 +++++++++++++++++++++
8
1 file changed, 14 insertions(+), 6 deletions(-)
17
hw/arm/allwinner-a10.c | 18 ++++++++++++++++++
18
hw/arm/cubieboard.c | 5 +++++
19
3 files changed, 44 insertions(+)
9
20
10
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
21
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
11
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
12
--- a/hw/timer/imx_epit.c
23
--- a/include/hw/arm/allwinner-a10.h
13
+++ b/hw/timer/imx_epit.c
24
+++ b/include/hw/arm/allwinner-a10.h
14
@@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s)
25
@@ -XXX,XX +XXX,XX @@
15
/*
26
#include "hw/misc/allwinner-a10-ccm.h"
16
* This is called both on hardware (device) reset and software reset.
27
#include "hw/misc/allwinner-a10-dramc.h"
17
*/
28
#include "hw/i2c/allwinner-i2c.h"
18
-static void imx_epit_reset(DeviceState *dev)
29
+#include "sysemu/block-backend.h"
19
+static void imx_epit_reset(IMXEPITState *s, bool is_hard_reset)
30
20
{
31
#include "target/arm/cpu.h"
21
- IMXEPITState *s = IMX_EPIT(dev);
32
#include "qom/object.h"
22
-
33
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
23
/* Soft reset doesn't touch some bits; hard reset clears them */
34
OHCISysBusState ohci[AW_A10_NUM_USB];
24
- s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN);
35
};
25
+ if (is_hard_reset) {
36
26
+ s->cr = 0;
37
+/**
27
+ } else {
38
+ * Emulate Boot ROM firmware setup functionality.
28
+ s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN);
39
+ *
40
+ * A real Allwinner A10 SoC contains a Boot ROM
41
+ * which is the first code that runs right after
42
+ * the SoC is powered on. The Boot ROM is responsible
43
+ * for loading user code (e.g. a bootloader) from any
44
+ * of the supported external devices and writing the
45
+ * downloaded code to internal SRAM. After loading the SoC
46
+ * begins executing the code written to SRAM.
47
+ *
48
+ * This function emulates the Boot ROM by copying 32 KiB
49
+ * of data at offset 8 KiB from the given block device and writes it to
50
+ * the start of the first internal SRAM memory.
51
+ *
52
+ * @s: Allwinner A10 state object pointer
53
+ * @blk: Block backend device object pointer
54
+ */
55
+void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk);
56
+
57
#endif
58
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
59
index XXXXXXX..XXXXXXX 100644
60
--- a/hw/arm/allwinner-a10.c
61
+++ b/hw/arm/allwinner-a10.c
62
@@ -XXX,XX +XXX,XX @@
63
#include "sysemu/sysemu.h"
64
#include "hw/boards.h"
65
#include "hw/usb/hcd-ohci.h"
66
+#include "hw/loader.h"
67
68
+#define AW_A10_SRAM_A_BASE 0x00000000
69
#define AW_A10_DRAMC_BASE 0x01c01000
70
#define AW_A10_MMC0_BASE 0x01c0f000
71
#define AW_A10_CCM_BASE 0x01c20000
72
@@ -XXX,XX +XXX,XX @@
73
#define AW_A10_RTC_BASE 0x01c20d00
74
#define AW_A10_I2C0_BASE 0x01c2ac00
75
76
+void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk)
77
+{
78
+ const int64_t rom_size = 32 * KiB;
79
+ g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
80
+
81
+ if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
82
+ error_setg(&error_fatal, "%s: failed to read BlockBackend data",
83
+ __func__);
84
+ return;
29
+ }
85
+ }
30
s->sr = 0;
86
+
31
s->lr = EPIT_TIMER_MAX;
87
+ rom_add_blob("allwinner-a10.bootrom", buffer, rom_size,
32
s->cmp = 0;
88
+ rom_size, AW_A10_SRAM_A_BASE,
33
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
89
+ NULL, NULL, NULL, NULL, false);
34
s->cr = value & 0x03ffffff;
35
if (s->cr & CR_SWR) {
36
/* handle the reset */
37
- imx_epit_reset(DEVICE(s));
38
+ imx_epit_reset(s, false);
39
}
40
41
/*
42
@@ -XXX,XX +XXX,XX @@ static void imx_epit_realize(DeviceState *dev, Error **errp)
43
s->timer_cmp = ptimer_init(imx_epit_cmp, s, PTIMER_POLICY_LEGACY);
44
}
45
46
+static void imx_epit_dev_reset(DeviceState *dev)
47
+{
48
+ IMXEPITState *s = IMX_EPIT(dev);
49
+ imx_epit_reset(s, true);
50
+}
90
+}
51
+
91
+
52
static void imx_epit_class_init(ObjectClass *klass, void *data)
92
static void aw_a10_init(Object *obj)
53
{
93
{
54
DeviceClass *dc = DEVICE_CLASS(klass);
94
AwA10State *s = AW_A10(obj);
55
95
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
56
dc->realize = imx_epit_realize;
96
index XXXXXXX..XXXXXXX 100644
57
- dc->reset = imx_epit_reset;
97
--- a/hw/arm/cubieboard.c
58
+ dc->reset = imx_epit_dev_reset;
98
+++ b/hw/arm/cubieboard.c
59
dc->vmsd = &vmstate_imx_timer_epit;
99
@@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine)
60
dc->desc = "i.MX periodic timer";
100
memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
61
}
101
machine->ram);
102
103
+ /* Load target kernel or start using BootROM */
104
+ if (!machine->kernel_filename && blk && blk_is_available(blk)) {
105
+ /* Use Boot ROM to copy data from SD card to SRAM */
106
+ allwinner_a10_bootrom_setup(a10, blk);
107
+ }
108
/* TODO create and connect IDE devices for ide_drive_get() */
109
110
cubieboard_binfo.ram_size = machine->ram_size;
62
--
111
--
63
2.25.1
112
2.34.1
diff view generated by jsdifflib
New patch
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
1
2
3
Cubieboard now can boot directly from SD card, without the need to pass
4
`-kernel` parameter. Update Avocado tests to cover this functionality.
5
6
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
7
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
8
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
9
Message-id: 20221226220303.14420-8-strahinja.p.jankovic@gmail.com
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
12
tests/avocado/boot_linux_console.py | 47 +++++++++++++++++++++++++++++
13
1 file changed, 47 insertions(+)
14
15
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
16
index XXXXXXX..XXXXXXX 100644
17
--- a/tests/avocado/boot_linux_console.py
18
+++ b/tests/avocado/boot_linux_console.py
19
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self):
20
'sda')
21
# cubieboard's reboot is not functioning; omit reboot test.
22
23
+ @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
24
+ def test_arm_cubieboard_openwrt_22_03_2(self):
25
+ """
26
+ :avocado: tags=arch:arm
27
+ :avocado: tags=machine:cubieboard
28
+ :avocado: tags=device:sd
29
+ """
30
+
31
+ # This test download a 7.5 MiB compressed image and expand it
32
+ # to 126 MiB.
33
+ image_url = ('https://downloads.openwrt.org/releases/22.03.2/targets/'
34
+ 'sunxi/cortexa8/openwrt-22.03.2-sunxi-cortexa8-'
35
+ 'cubietech_a10-cubieboard-ext4-sdcard.img.gz')
36
+ image_hash = ('94b5ecbfbc0b3b56276e5146b899eafa'
37
+ '2ac5dc2d08733d6705af9f144f39f554')
38
+ image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash,
39
+ algorithm='sha256')
40
+ image_path = archive.extract(image_path_gz, self.workdir)
41
+ image_pow2ceil_expand(image_path)
42
+
43
+ self.vm.set_console()
44
+ self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
45
+ '-nic', 'user',
46
+ '-no-reboot')
47
+ self.vm.launch()
48
+
49
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
50
+ 'usbcore.nousb '
51
+ 'noreboot')
52
+
53
+ self.wait_for_console_pattern('U-Boot SPL')
54
+
55
+ interrupt_interactive_console_until_pattern(
56
+ self, 'Hit any key to stop autoboot:', '=>')
57
+ exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
58
+ kernel_command_line + "'", '=>')
59
+ exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...');
60
+
61
+ self.wait_for_console_pattern(
62
+ 'Please press Enter to activate this console.')
63
+
64
+ exec_command_and_wait_for_pattern(self, ' ', 'root@')
65
+
66
+ exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
67
+ 'Allwinner sun4i/sun5i')
68
+ # cubieboard's reboot is not functioning; omit reboot test.
69
+
70
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
71
def test_arm_quanta_gsj(self):
72
"""
73
--
74
2.34.1
diff view generated by jsdifflib
1
From: Alex Bennée <alex.bennee@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
The check semihosting_enabled() wants to know if the guest is
3
Don't dereference CPUTLBEntryFull until we verify that
4
currently in user mode. Unlike the other cases the test was inverted
4
the page is valid. Move the other user-only info field
5
causing us to block semihosting calls in non-EL0 modes.
5
updates after the valid check to match.
6
6
7
Cc: qemu-stable@nongnu.org
7
Cc: qemu-stable@nongnu.org
8
Fixes: 19b26317e9 (target/arm: Honour -semihosting-config userspace=on)
8
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412
9
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20230104190056.305143-1-richard.henderson@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
---
13
target/arm/translate.c | 2 +-
14
target/arm/sve_helper.c | 14 +++++++++-----
14
1 file changed, 1 insertion(+), 1 deletion(-)
15
1 file changed, 9 insertions(+), 5 deletions(-)
15
16
16
diff --git a/target/arm/translate.c b/target/arm/translate.c
17
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/target/arm/translate.c
19
--- a/target/arm/sve_helper.c
19
+++ b/target/arm/translate.c
20
+++ b/target/arm/sve_helper.c
20
@@ -XXX,XX +XXX,XX @@ static inline void gen_hlt(DisasContext *s, int imm)
21
@@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
21
* semihosting, to provide some semblance of security
22
#ifdef CONFIG_USER_ONLY
22
* (and for consistency with our 32-bit semihosting).
23
flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault,
23
*/
24
&info->host, retaddr);
24
- if (semihosting_enabled(s->current_el != 0) &&
25
- memset(&info->attrs, 0, sizeof(info->attrs));
25
+ if (semihosting_enabled(s->current_el == 0) &&
26
- /* Require both ANON and MTE; see allocation_tag_mem(). */
26
(imm == (s->thumb ? 0x3c : 0xf000))) {
27
- info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
27
gen_exception_internal_insn(s, EXCP_SEMIHOST);
28
#else
28
return;
29
CPUTLBEntryFull *full;
30
flags = probe_access_full(env, addr, access_type, mmu_idx, nofault,
31
&info->host, &full, retaddr);
32
- info->attrs = full->attrs;
33
- info->tagged = full->pte_attrs == 0xf0;
34
#endif
35
info->flags = flags;
36
37
@@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
38
return false;
39
}
40
41
+#ifdef CONFIG_USER_ONLY
42
+ memset(&info->attrs, 0, sizeof(info->attrs));
43
+ /* Require both ANON and MTE; see allocation_tag_mem(). */
44
+ info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
45
+#else
46
+ info->attrs = full->attrs;
47
+ info->tagged = full->pte_attrs == 0xf0;
48
+#endif
49
+
50
/* Ensure that info->host[] is relative to addr, not addr + mem_off. */
51
info->host -= mem_off;
52
return true;
29
--
53
--
30
2.25.1
54
2.34.1
31
55
32
56
diff view generated by jsdifflib
1
From: Claudio Fontana <cfontana@suse.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Remove some unused headers.
3
Since pxa255_init() must map the device in the system memory,
4
there is no point in passing get_system_memory() by argument.
4
5
5
Signed-off-by: Claudio Fontana <cfontana@suse.de>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Acked-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Claudio Fontana <cfontana@suse.de>
8
Message-id: 20230109115316.2235-2-philmd@linaro.org
8
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
Message-id: 20221213190537.511-7-farosas@suse.de
11
[added back some includes that are still needed at this point]
12
Signed-off-by: Fabiano Rosas <farosas@suse.de>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
10
---
15
target/arm/cpu.c | 1 -
11
include/hw/arm/pxa.h | 2 +-
16
target/arm/cpu64.c | 6 ------
12
hw/arm/gumstix.c | 3 +--
17
2 files changed, 7 deletions(-)
13
hw/arm/pxa2xx.c | 4 +++-
14
hw/arm/tosa.c | 2 +-
15
4 files changed, 6 insertions(+), 5 deletions(-)
18
16
19
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
17
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
20
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
21
--- a/target/arm/cpu.c
19
--- a/include/hw/arm/pxa.h
22
+++ b/target/arm/cpu.c
20
+++ b/include/hw/arm/pxa.h
21
@@ -XXX,XX +XXX,XX @@ struct PXA2xxI2SState {
22
23
PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size,
24
const char *revision);
25
-PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size);
26
+PXA2xxState *pxa255_init(unsigned int sdram_size);
27
28
#endif /* PXA_H */
29
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/gumstix.c
32
+++ b/hw/arm/gumstix.c
33
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
34
{
35
PXA2xxState *cpu;
36
DriveInfo *dinfo;
37
- MemoryRegion *address_space_mem = get_system_memory();
38
39
uint32_t connex_rom = 0x01000000;
40
uint32_t connex_ram = 0x04000000;
41
42
- cpu = pxa255_init(address_space_mem, connex_ram);
43
+ cpu = pxa255_init(connex_ram);
44
45
dinfo = drive_get(IF_PFLASH, 0, 0);
46
if (!dinfo && !qtest_enabled()) {
47
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/arm/pxa2xx.c
50
+++ b/hw/arm/pxa2xx.c
23
@@ -XXX,XX +XXX,XX @@
51
@@ -XXX,XX +XXX,XX @@
24
#include "target/arm/idau.h"
52
#include "qemu/error-report.h"
25
#include "qemu/module.h"
53
#include "qemu/module.h"
26
#include "qapi/error.h"
54
#include "qapi/error.h"
27
-#include "qapi/visitor.h"
55
+#include "exec/address-spaces.h"
28
#include "cpu.h"
56
#include "cpu.h"
29
#ifdef CONFIG_TCG
57
#include "hw/sysbus.h"
30
#include "hw/core/tcg-cpu-ops.h"
58
#include "migration/vmstate.h"
31
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
59
@@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
60
}
61
62
/* Initialise a PXA255 integrated chip (ARM based core). */
63
-PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
64
+PXA2xxState *pxa255_init(unsigned int sdram_size)
65
{
66
+ MemoryRegion *address_space = get_system_memory();
67
PXA2xxState *s;
68
int i;
69
DriveInfo *dinfo;
70
diff --git a/hw/arm/tosa.c b/hw/arm/tosa.c
32
index XXXXXXX..XXXXXXX 100644
71
index XXXXXXX..XXXXXXX 100644
33
--- a/target/arm/cpu64.c
72
--- a/hw/arm/tosa.c
34
+++ b/target/arm/cpu64.c
73
+++ b/hw/arm/tosa.c
35
@@ -XXX,XX +XXX,XX @@
74
@@ -XXX,XX +XXX,XX @@ static void tosa_init(MachineState *machine)
36
#include "qemu/osdep.h"
75
TC6393xbState *tmio;
37
#include "qapi/error.h"
76
DeviceState *scp0, *scp1;
38
#include "cpu.h"
77
39
-#ifdef CONFIG_TCG
78
- mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
40
-#include "hw/core/tcg-cpu-ops.h"
79
+ mpu = pxa255_init(tosa_binfo.ram_size);
41
-#endif /* CONFIG_TCG */
80
42
#include "qemu/module.h"
81
memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
43
-#if !defined(CONFIG_USER_ONLY)
82
memory_region_add_subregion(address_space_mem, 0, rom);
44
-#include "hw/loader.h"
45
-#endif
46
#include "sysemu/kvm.h"
47
#include "sysemu/hvf.h"
48
#include "kvm_arm.h"
49
--
83
--
50
2.25.1
84
2.34.1
85
86
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
This function is not used anywhere outside this file,
3
Since pxa270_init() must map the device in the system memory,
4
so we can make the function "static void".
4
there is no point in passing get_system_memory() by argument.
5
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
Message-id: 20230109115316.2235-3-philmd@linaro.org
9
Message-id: 20221216214924.4711-2-philmd@linaro.org
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
10
---
12
include/hw/arm/smmu-common.h | 3 ---
11
include/hw/arm/pxa.h | 3 +--
13
hw/arm/smmu-common.c | 2 +-
12
hw/arm/gumstix.c | 3 +--
14
2 files changed, 1 insertion(+), 4 deletions(-)
13
hw/arm/mainstone.c | 10 ++++------
14
hw/arm/pxa2xx.c | 4 ++--
15
hw/arm/spitz.c | 6 ++----
16
hw/arm/z2.c | 3 +--
17
6 files changed, 11 insertions(+), 18 deletions(-)
15
18
16
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
19
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/include/hw/arm/smmu-common.h
21
--- a/include/hw/arm/pxa.h
19
+++ b/include/hw/arm/smmu-common.h
22
+++ b/include/hw/arm/pxa.h
20
@@ -XXX,XX +XXX,XX @@ void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
23
@@ -XXX,XX +XXX,XX @@ struct PXA2xxI2SState {
21
/* Unmap the range of all the notifiers registered to any IOMMU mr */
24
22
void smmu_inv_notifiers_all(SMMUState *s);
25
# define PA_FMT            "0x%08lx"
23
26
24
-/* Unmap the range of all the notifiers registered to @mr */
27
-PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size,
25
-void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr);
28
- const char *revision);
26
-
29
+PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision);
27
#endif /* HW_ARM_SMMU_COMMON_H */
30
PXA2xxState *pxa255_init(unsigned int sdram_size);
28
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
31
32
#endif /* PXA_H */
33
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
29
index XXXXXXX..XXXXXXX 100644
34
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/smmu-common.c
35
--- a/hw/arm/gumstix.c
31
+++ b/hw/arm/smmu-common.c
36
+++ b/hw/arm/gumstix.c
32
@@ -XXX,XX +XXX,XX @@ static void smmu_unmap_notifier_range(IOMMUNotifier *n)
37
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
38
{
39
PXA2xxState *cpu;
40
DriveInfo *dinfo;
41
- MemoryRegion *address_space_mem = get_system_memory();
42
43
uint32_t verdex_rom = 0x02000000;
44
uint32_t verdex_ram = 0x10000000;
45
46
- cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type);
47
+ cpu = pxa270_init(verdex_ram, machine->cpu_type);
48
49
dinfo = drive_get(IF_PFLASH, 0, 0);
50
if (!dinfo && !qtest_enabled()) {
51
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
52
index XXXXXXX..XXXXXXX 100644
53
--- a/hw/arm/mainstone.c
54
+++ b/hw/arm/mainstone.c
55
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info mainstone_binfo = {
56
.ram_size = 0x04000000,
57
};
58
59
-static void mainstone_common_init(MemoryRegion *address_space_mem,
60
- MachineState *machine,
61
+static void mainstone_common_init(MachineState *machine,
62
enum mainstone_model_e model, int arm_id)
63
{
64
uint32_t sector_len = 256 * 1024;
65
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
66
MemoryRegion *rom = g_new(MemoryRegion, 1);
67
68
/* Setup CPU & memory */
69
- mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size,
70
- machine->cpu_type);
71
+ mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type);
72
memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
73
&error_fatal);
74
- memory_region_add_subregion(address_space_mem, 0, rom);
75
+ memory_region_add_subregion(get_system_memory(), 0x00000000, rom);
76
77
/* There are two 32MiB flash devices on the board */
78
for (i = 0; i < 2; i ++) {
79
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
80
81
static void mainstone_init(MachineState *machine)
82
{
83
- mainstone_common_init(get_system_memory(), machine, mainstone, 0x196);
84
+ mainstone_common_init(machine, mainstone, 0x196);
33
}
85
}
34
86
35
/* Unmap all notifiers attached to @mr */
87
static void mainstone2_machine_init(MachineClass *mc)
36
-inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr)
88
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
37
+static void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr)
89
index XXXXXXX..XXXXXXX 100644
90
--- a/hw/arm/pxa2xx.c
91
+++ b/hw/arm/pxa2xx.c
92
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_reset(void *opaque, int line, int level)
93
}
94
95
/* Initialise a PXA270 integrated chip (ARM based core). */
96
-PXA2xxState *pxa270_init(MemoryRegion *address_space,
97
- unsigned int sdram_size, const char *cpu_type)
98
+PXA2xxState *pxa270_init(unsigned int sdram_size, const char *cpu_type)
38
{
99
{
39
IOMMUNotifier *n;
100
+ MemoryRegion *address_space = get_system_memory();
40
101
PXA2xxState *s;
102
int i;
103
DriveInfo *dinfo;
104
diff --git a/hw/arm/spitz.c b/hw/arm/spitz.c
105
index XXXXXXX..XXXXXXX 100644
106
--- a/hw/arm/spitz.c
107
+++ b/hw/arm/spitz.c
108
@@ -XXX,XX +XXX,XX @@ static void spitz_common_init(MachineState *machine)
109
SpitzMachineState *sms = SPITZ_MACHINE(machine);
110
enum spitz_model_e model = smc->model;
111
PXA2xxState *mpu;
112
- MemoryRegion *address_space_mem = get_system_memory();
113
MemoryRegion *rom = g_new(MemoryRegion, 1);
114
115
/* Setup CPU & memory */
116
- mpu = pxa270_init(address_space_mem, spitz_binfo.ram_size,
117
- machine->cpu_type);
118
+ mpu = pxa270_init(spitz_binfo.ram_size, machine->cpu_type);
119
sms->mpu = mpu;
120
121
sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M);
122
123
memory_region_init_rom(rom, NULL, "spitz.rom", SPITZ_ROM, &error_fatal);
124
- memory_region_add_subregion(address_space_mem, 0, rom);
125
+ memory_region_add_subregion(get_system_memory(), 0, rom);
126
127
/* Setup peripherals */
128
spitz_keyboard_register(mpu);
129
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
130
index XXXXXXX..XXXXXXX 100644
131
--- a/hw/arm/z2.c
132
+++ b/hw/arm/z2.c
133
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aer915_info = {
134
135
static void z2_init(MachineState *machine)
136
{
137
- MemoryRegion *address_space_mem = get_system_memory();
138
uint32_t sector_len = 0x10000;
139
PXA2xxState *mpu;
140
DriveInfo *dinfo;
141
@@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine)
142
DeviceState *wm;
143
144
/* Setup CPU & memory */
145
- mpu = pxa270_init(address_space_mem, z2_binfo.ram_size, machine->cpu_type);
146
+ mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type);
147
148
dinfo = drive_get(IF_PFLASH, 0, 0);
149
if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
41
--
150
--
42
2.25.1
151
2.34.1
43
152
44
153
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
3
IEC binary prefixes ease code review: the unit is explicit.
4
5
Add definitions for RAM / Flash / Flash blocksize.
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-4-philmd@linaro.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
---
11
---
6
include/hw/timer/imx_epit.h | 2 ++
12
hw/arm/collie.c | 16 ++++++++++------
7
hw/timer/imx_epit.c | 12 ++++++------
13
1 file changed, 10 insertions(+), 6 deletions(-)
8
2 files changed, 8 insertions(+), 6 deletions(-)
9
14
10
diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h
15
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
11
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
12
--- a/include/hw/timer/imx_epit.h
17
--- a/hw/arm/collie.c
13
+++ b/include/hw/timer/imx_epit.h
18
+++ b/hw/arm/collie.c
14
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
15
#define CR_CLKSRC_SHIFT (24)
20
#include "cpu.h"
16
#define CR_CLKSRC_BITS (2)
21
#include "qom/object.h"
17
22
18
+#define SR_OCIF (1 << 0)
23
+#define RAM_SIZE (512 * MiB)
24
+#define FLASH_SIZE (32 * MiB)
25
+#define FLASH_SECTOR_SIZE (64 * KiB)
19
+
26
+
20
#define EPIT_TIMER_MAX 0XFFFFFFFFUL
27
struct CollieMachineState {
21
28
MachineState parent;
22
#define TYPE_IMX_EPIT "imx.epit"
29
23
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
30
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(CollieMachineState, COLLIE_MACHINE)
24
index XXXXXXX..XXXXXXX 100644
31
25
--- a/hw/timer/imx_epit.c
32
static struct arm_boot_info collie_binfo = {
26
+++ b/hw/timer/imx_epit.c
33
.loader_start = SA_SDCS0,
27
@@ -XXX,XX +XXX,XX @@ static const IMXClk imx_epit_clocks[] = {
34
- .ram_size = 0x20000000,
28
*/
35
+ .ram_size = RAM_SIZE,
29
static void imx_epit_update_int(IMXEPITState *s)
36
};
30
{
37
31
- if (s->sr && (s->cr & CR_OCIEN) && (s->cr & CR_EN)) {
38
static void collie_init(MachineState *machine)
32
+ if ((s->sr & SR_OCIF) && (s->cr & CR_OCIEN) && (s->cr & CR_EN)) {
39
@@ -XXX,XX +XXX,XX @@ static void collie_init(MachineState *machine)
33
qemu_irq_raise(s->irq);
40
memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
34
} else {
41
35
qemu_irq_lower(s->irq);
42
dinfo = drive_get(IF_PFLASH, 0, 0);
36
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
43
- pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
37
break;
44
+ pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE,
38
45
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
39
case 1: /* SR - ACK*/
46
- 64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
40
- /* writing 1 to OCIF clears the OCIF bit */
47
+ FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
41
- if (value & 0x01) {
48
42
- s->sr = 0;
49
dinfo = drive_get(IF_PFLASH, 0, 1);
43
+ /* writing 1 to SR.OCIF clears this bit and turns the interrupt off */
50
- pflash_cfi01_register(SA_CS1, "collie.fl2", 0x02000000,
44
+ if (value & SR_OCIF) {
51
+ pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE,
45
+ s->sr = 0; /* SR.OCIF is the only bit in this register anyway */
52
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
46
imx_epit_update_int(s);
53
- 64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
47
}
54
+ FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
48
break;
55
49
@@ -XXX,XX +XXX,XX @@ static void imx_epit_cmp(void *opaque)
56
sysbus_create_simple("scoop", 0x40800000, NULL);
50
IMXEPITState *s = IMX_EPIT(opaque);
57
51
58
@@ -XXX,XX +XXX,XX @@ static void collie_machine_class_init(ObjectClass *oc, void *data)
52
DPRINTF("sr was %d\n", s->sr);
59
mc->init = collie_init;
53
-
60
mc->ignore_memory_transaction_failures = true;
54
- s->sr = 1;
61
mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110");
55
+ /* Set interrupt status bit SR.OCIF and update the interrupt state */
62
- mc->default_ram_size = 0x20000000;
56
+ s->sr |= SR_OCIF;
63
+ mc->default_ram_size = RAM_SIZE;
57
imx_epit_update_int(s);
64
mc->default_ram_id = "strongarm.sdram";
58
}
65
}
59
66
60
--
67
--
61
2.25.1
68
2.34.1
69
70
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The interrupt state can change due to:
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
- reset clears both SR.OCIF and CR.OCIE
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
- write to CR.EN or CR.OCIE
5
Message-id: 20230109115316.2235-5-philmd@linaro.org
6
7
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
7
---
11
hw/timer/imx_epit.c | 16 ++++++++++++----
8
hw/arm/collie.c | 17 +++++++----------
12
1 file changed, 12 insertions(+), 4 deletions(-)
9
1 file changed, 7 insertions(+), 10 deletions(-)
13
10
14
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
11
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
15
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/timer/imx_epit.c
13
--- a/hw/arm/collie.c
17
+++ b/hw/timer/imx_epit.c
14
+++ b/hw/arm/collie.c
18
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
15
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info collie_binfo = {
19
if (s->cr & CR_SWR) {
16
20
/* handle the reset */
17
static void collie_init(MachineState *machine)
21
imx_epit_reset(DEVICE(s));
18
{
22
- /*
19
- DriveInfo *dinfo;
23
- * TODO: could we 'break' here? following operations appear
20
MachineClass *mc = MACHINE_GET_CLASS(machine);
24
- * to duplicate the work imx_epit_reset() already did.
21
CollieMachineState *cms = COLLIE_MACHINE(machine);
25
- */
22
26
}
23
@@ -XXX,XX +XXX,XX @@ static void collie_init(MachineState *machine)
27
24
28
+ /*
25
memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
29
+ * The interrupt state can change due to:
26
30
+ * - reset clears both SR.OCIF and CR.OCIE
27
- dinfo = drive_get(IF_PFLASH, 0, 0);
31
+ * - write to CR.EN or CR.OCIE
28
- pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE,
32
+ */
29
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
33
+ imx_epit_update_int(s);
30
- FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
34
+
31
-
35
+ /*
32
- dinfo = drive_get(IF_PFLASH, 0, 1);
36
+ * TODO: could we 'break' here for reset? following operations appear
33
- pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE,
37
+ * to duplicate the work imx_epit_reset() already did.
34
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
38
+ */
35
- FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
39
+
36
+ for (unsigned i = 0; i < 2; i++) {
40
ptimer_transaction_begin(s->timer_cmp);
37
+ DriveInfo *dinfo = drive_get(IF_PFLASH, 0, i);
41
ptimer_transaction_begin(s->timer_reload);
38
+ pflash_cfi01_register(i ? SA_CS1 : SA_CS0,
39
+ i ? "collie.fl2" : "collie.fl1", FLASH_SIZE,
40
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
41
+ FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
42
+ }
43
44
sysbus_create_simple("scoop", 0x40800000, NULL);
42
45
43
--
46
--
44
2.25.1
47
2.34.1
48
49
diff view generated by jsdifflib
1
From: Stephen Longfield <slongfield@google.com>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
Size is used at lines 1088/1188 for the loop, which reads the last 4
3
Add a comment describing the Connex uses a Numonyx RC28F128J3F75
4
bytes from the crc_ptr so it does need to get increased, however it
4
flash, and the Verdex uses a Micron RC28F256P30TFA.
5
shouldn't be increased before the buffer is passed to CRC computation,
6
or the crc32 function will access uninitialized memory.
7
5
8
This was pointed out to me by clg@kaod.org during the code review of
6
Correct the Verdex machine description (we model the 'Pro' board).
9
a similar patch to hw/net/ftgmac100.c
10
7
11
Change-Id: Ib0464303b191af1e28abeb2f5105eb25aadb5e9b
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
12
Signed-off-by: Stephen Longfield <slongfield@google.com>
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Reviewed-by: Patrick Venture <venture@google.com>
10
Message-id: 20230109115316.2235-6-philmd@linaro.org
14
Message-id: 20221221183202.3788132-1-slongfield@google.com
11
Message-Id: <20200223231044.8003-3-philmd@redhat.com>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
13
---
18
hw/net/imx_fec.c | 8 ++++----
14
hw/arm/gumstix.c | 6 ++++--
19
1 file changed, 4 insertions(+), 4 deletions(-)
15
1 file changed, 4 insertions(+), 2 deletions(-)
20
16
21
diff --git a/hw/net/imx_fec.c b/hw/net/imx_fec.c
17
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
22
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/net/imx_fec.c
19
--- a/hw/arm/gumstix.c
24
+++ b/hw/net/imx_fec.c
20
+++ b/hw/arm/gumstix.c
25
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf,
21
@@ -XXX,XX +XXX,XX @@
26
return 0;
22
* Contributions after 2012-01-13 are licensed under the terms of the
23
* GNU GPL, version 2 or (at your option) any later version.
24
*/
25
-
26
+
27
/*
28
* Example usage:
29
*
30
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
31
exit(1);
27
}
32
}
28
33
29
- /* 4 bytes for the CRC. */
34
+ /* Numonyx RC28F128J3F75 */
30
- size += 4;
35
if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
31
crc = cpu_to_be32(crc32(~0, buf, size));
36
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
32
+ /* Increase size by 4, loop below reads the last 4 bytes from crc_ptr. */
37
sector_len, 2, 0, 0, 0, 0, 0)) {
33
+ size += 4;
38
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
34
crc_ptr = (uint8_t *) &crc;
39
exit(1);
35
36
/* Huge frames are truncated. */
37
@@ -XXX,XX +XXX,XX @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,
38
return 0;
39
}
40
}
40
41
41
- /* 4 bytes for the CRC. */
42
+ /* Micron RC28F256P30TFA */
42
- size += 4;
43
if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
43
crc = cpu_to_be32(crc32(~0, buf, size));
44
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
44
+ /* Increase size by 4, loop below reads the last 4 bytes from crc_ptr. */
45
sector_len, 2, 0, 0, 0, 0, 0)) {
45
+ size += 4;
46
@@ -XXX,XX +XXX,XX @@ static void verdex_class_init(ObjectClass *oc, void *data)
46
crc_ptr = (uint8_t *) &crc;
47
{
47
48
MachineClass *mc = MACHINE_CLASS(oc);
48
if (shift16) {
49
50
- mc->desc = "Gumstix Verdex (PXA270)";
51
+ mc->desc = "Gumstix Verdex Pro XL6P COMs (PXA270)";
52
mc->init = verdex_init;
53
mc->ignore_memory_transaction_failures = true;
54
mc->default_cpu_type = ARM_CPU_TYPE_NAME("pxa270-c0");
49
--
55
--
50
2.25.1
56
2.34.1
57
58
diff view generated by jsdifflib
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
IRQs were not associated to the various GPIO devices inside i.MX7D.
3
IEC binary prefixes ease code review: the unit is explicit.
4
This patch brings the i.MX7D on par with i.MX6.
5
4
6
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
5
Add definitions for RAM / Flash / Flash blocksize.
7
Message-id: 20221226101418.415170-1-jcd@tribudubois.net
6
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-7-philmd@linaro.org
10
Message-Id: <20200223231044.8003-3-philmd@redhat.com>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
12
---
11
include/hw/arm/fsl-imx7.h | 15 +++++++++++++++
13
hw/arm/gumstix.c | 27 ++++++++++++++-------------
12
hw/arm/fsl-imx7.c | 31 ++++++++++++++++++++++++++++++-
14
1 file changed, 14 insertions(+), 13 deletions(-)
13
2 files changed, 45 insertions(+), 1 deletion(-)
14
15
15
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
16
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
16
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/arm/fsl-imx7.h
18
--- a/hw/arm/gumstix.c
18
+++ b/include/hw/arm/fsl-imx7.h
19
+++ b/hw/arm/gumstix.c
19
@@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs {
20
@@ -XXX,XX +XXX,XX @@
20
FSL_IMX7_GPT3_IRQ = 53,
21
*/
21
FSL_IMX7_GPT4_IRQ = 52,
22
22
23
#include "qemu/osdep.h"
23
+ FSL_IMX7_GPIO1_LOW_IRQ = 64,
24
+#include "qemu/units.h"
24
+ FSL_IMX7_GPIO1_HIGH_IRQ = 65,
25
#include "qemu/error-report.h"
25
+ FSL_IMX7_GPIO2_LOW_IRQ = 66,
26
#include "hw/arm/pxa.h"
26
+ FSL_IMX7_GPIO2_HIGH_IRQ = 67,
27
#include "net/net.h"
27
+ FSL_IMX7_GPIO3_LOW_IRQ = 68,
28
@@ -XXX,XX +XXX,XX @@
28
+ FSL_IMX7_GPIO3_HIGH_IRQ = 69,
29
#include "sysemu/qtest.h"
29
+ FSL_IMX7_GPIO4_LOW_IRQ = 70,
30
#include "cpu.h"
30
+ FSL_IMX7_GPIO4_HIGH_IRQ = 71,
31
31
+ FSL_IMX7_GPIO5_LOW_IRQ = 72,
32
-static const int sector_len = 128 * 1024;
32
+ FSL_IMX7_GPIO5_HIGH_IRQ = 73,
33
+#define CONNEX_FLASH_SIZE (16 * MiB)
33
+ FSL_IMX7_GPIO6_LOW_IRQ = 74,
34
+#define CONNEX_RAM_SIZE (64 * MiB)
34
+ FSL_IMX7_GPIO6_HIGH_IRQ = 75,
35
+ FSL_IMX7_GPIO7_LOW_IRQ = 76,
36
+ FSL_IMX7_GPIO7_HIGH_IRQ = 77,
37
+
35
+
38
FSL_IMX7_WDOG1_IRQ = 78,
36
+#define VERDEX_FLASH_SIZE (32 * MiB)
39
FSL_IMX7_WDOG2_IRQ = 79,
37
+#define VERDEX_RAM_SIZE (256 * MiB)
40
FSL_IMX7_WDOG3_IRQ = 10,
41
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/arm/fsl-imx7.c
44
+++ b/hw/arm/fsl-imx7.c
45
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
46
FSL_IMX7_GPIO7_ADDR,
47
};
48
49
+ static const int FSL_IMX7_GPIOn_LOW_IRQ[FSL_IMX7_NUM_GPIOS] = {
50
+ FSL_IMX7_GPIO1_LOW_IRQ,
51
+ FSL_IMX7_GPIO2_LOW_IRQ,
52
+ FSL_IMX7_GPIO3_LOW_IRQ,
53
+ FSL_IMX7_GPIO4_LOW_IRQ,
54
+ FSL_IMX7_GPIO5_LOW_IRQ,
55
+ FSL_IMX7_GPIO6_LOW_IRQ,
56
+ FSL_IMX7_GPIO7_LOW_IRQ,
57
+ };
58
+
38
+
59
+ static const int FSL_IMX7_GPIOn_HIGH_IRQ[FSL_IMX7_NUM_GPIOS] = {
39
+#define FLASH_SECTOR_SIZE (128 * KiB)
60
+ FSL_IMX7_GPIO1_HIGH_IRQ,
40
61
+ FSL_IMX7_GPIO2_HIGH_IRQ,
41
static void connex_init(MachineState *machine)
62
+ FSL_IMX7_GPIO3_HIGH_IRQ,
42
{
63
+ FSL_IMX7_GPIO4_HIGH_IRQ,
43
PXA2xxState *cpu;
64
+ FSL_IMX7_GPIO5_HIGH_IRQ,
44
DriveInfo *dinfo;
65
+ FSL_IMX7_GPIO6_HIGH_IRQ,
45
66
+ FSL_IMX7_GPIO7_HIGH_IRQ,
46
- uint32_t connex_rom = 0x01000000;
67
+ };
47
- uint32_t connex_ram = 0x04000000;
68
+
48
-
69
sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), &error_abort);
49
- cpu = pxa255_init(connex_ram);
70
- sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, FSL_IMX7_GPIOn_ADDR[i]);
50
+ cpu = pxa255_init(CONNEX_RAM_SIZE);
71
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0,
51
72
+ FSL_IMX7_GPIOn_ADDR[i]);
52
dinfo = drive_get(IF_PFLASH, 0, 0);
73
+
53
if (!dinfo && !qtest_enabled()) {
74
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
54
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
75
+ qdev_get_gpio_in(DEVICE(&s->a7mpcore),
76
+ FSL_IMX7_GPIOn_LOW_IRQ[i]));
77
+
78
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 1,
79
+ qdev_get_gpio_in(DEVICE(&s->a7mpcore),
80
+ FSL_IMX7_GPIOn_HIGH_IRQ[i]));
81
}
55
}
82
56
83
/*
57
/* Numonyx RC28F128J3F75 */
58
- if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
59
+ if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
60
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
61
- sector_len, 2, 0, 0, 0, 0, 0)) {
62
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
63
error_report("Error registering flash memory");
64
exit(1);
65
}
66
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
67
PXA2xxState *cpu;
68
DriveInfo *dinfo;
69
70
- uint32_t verdex_rom = 0x02000000;
71
- uint32_t verdex_ram = 0x10000000;
72
-
73
- cpu = pxa270_init(verdex_ram, machine->cpu_type);
74
+ cpu = pxa270_init(VERDEX_RAM_SIZE, machine->cpu_type);
75
76
dinfo = drive_get(IF_PFLASH, 0, 0);
77
if (!dinfo && !qtest_enabled()) {
78
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
79
}
80
81
/* Micron RC28F256P30TFA */
82
- if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
83
+ if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
84
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
85
- sector_len, 2, 0, 0, 0, 0, 0)) {
86
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
87
error_report("Error registering flash memory");
88
exit(1);
89
}
84
--
90
--
85
2.25.1
91
2.34.1
92
93
diff view generated by jsdifflib
1
From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Cores with PMSA have the MPUIR register which has the
3
IEC binary prefixes ease code review: the unit is explicit.
4
same encoding as the MIDR alias with opc2=4. So we only
5
add that alias if we are not realizing a core that
6
implements PMSA.
7
4
8
Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
5
Add the FLASH_SECTOR_SIZE definition.
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20221206102504.165775-2-tobias.roehmel@rwth-aachen.de
9
Message-id: 20230109115316.2235-8-philmd@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
11
---
14
target/arm/helper.c | 13 +++++++++----
12
hw/arm/mainstone.c | 18 ++++++++++--------
15
1 file changed, 9 insertions(+), 4 deletions(-)
13
1 file changed, 10 insertions(+), 8 deletions(-)
16
14
17
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/helper.c
17
--- a/hw/arm/mainstone.c
20
+++ b/target/arm/helper.c
18
+++ b/hw/arm/mainstone.c
21
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
19
@@ -XXX,XX +XXX,XX @@
22
.access = PL1_R, .type = ARM_CP_NO_RAW, .resetvalue = cpu->midr,
20
* GNU GPL, version 2 or (at your option) any later version.
23
.fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid),
21
*/
24
.readfn = midr_read },
22
#include "qemu/osdep.h"
25
- /* crn = 0 op1 = 0 crm = 0 op2 = 4,7 : AArch32 aliases of MIDR */
23
+#include "qemu/units.h"
26
- { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST,
24
#include "qemu/error-report.h"
27
- .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4,
25
#include "qapi/error.h"
28
- .access = PL1_R, .resetvalue = cpu->midr },
26
#include "hw/arm/pxa.h"
29
+ /* crn = 0 op1 = 0 crm = 0 op2 = 7 : AArch32 aliases of MIDR */
27
@@ -XXX,XX +XXX,XX @@ static const struct keymap map[0xE0] = {
30
{ .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST,
28
31
.cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 7,
29
enum mainstone_model_e { mainstone };
32
.access = PL1_R, .resetvalue = cpu->midr },
30
33
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
31
-#define MAINSTONE_RAM    0x04000000
34
.accessfn = access_aa64_tid1,
32
-#define MAINSTONE_ROM    0x00800000
35
.type = ARM_CP_CONST, .resetvalue = cpu->revidr },
33
-#define MAINSTONE_FLASH    0x02000000
36
};
34
+#define MAINSTONE_RAM_SIZE (64 * MiB)
37
+ ARMCPRegInfo id_v8_midr_alias_cp_reginfo = {
35
+#define MAINSTONE_ROM_SIZE (8 * MiB)
38
+ .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST,
36
+#define MAINSTONE_FLASH_SIZE (32 * MiB)
39
+ .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4,
37
40
+ .access = PL1_R, .resetvalue = cpu->midr
38
static struct arm_boot_info mainstone_binfo = {
41
+ };
39
.loader_start = PXA2XX_SDRAM_BASE,
42
ARMCPRegInfo id_cp_reginfo[] = {
40
- .ram_size = 0x04000000,
43
/* These are common to v8 and pre-v8 */
41
+ .ram_size = MAINSTONE_RAM_SIZE,
44
{ .name = "CTR",
42
};
45
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
43
46
}
44
+#define FLASH_SECTOR_SIZE (256 * KiB)
47
if (arm_feature(env, ARM_FEATURE_V8)) {
45
+
48
define_arm_cp_regs(cpu, id_v8_midr_cp_reginfo);
46
static void mainstone_common_init(MachineState *machine,
49
+ if (!arm_feature(env, ARM_FEATURE_PMSA)) {
47
enum mainstone_model_e model, int arm_id)
50
+ define_one_arm_cp_reg(cpu, &id_v8_midr_alias_cp_reginfo);
48
{
51
+ }
49
- uint32_t sector_len = 256 * 1024;
52
} else {
50
hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
53
define_arm_cp_regs(cpu, id_pre_v8_midr_cp_reginfo);
51
PXA2xxState *mpu;
52
DeviceState *mst_irq;
53
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine,
54
55
/* Setup CPU & memory */
56
mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type);
57
- memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM,
58
+ memory_region_init_rom(rom, NULL, "mainstone.rom", MAINSTONE_ROM_SIZE,
59
&error_fatal);
60
memory_region_add_subregion(get_system_memory(), 0x00000000, rom);
61
62
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine,
63
dinfo = drive_get(IF_PFLASH, 0, i);
64
if (!pflash_cfi01_register(mainstone_flash_base[i],
65
i ? "mainstone.flash1" : "mainstone.flash0",
66
- MAINSTONE_FLASH,
67
+ MAINSTONE_FLASH_SIZE,
68
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
69
- sector_len, 4, 0, 0, 0, 0, 0)) {
70
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
71
error_report("Error registering flash memory");
72
exit(1);
54
}
73
}
55
--
74
--
56
2.25.1
75
2.34.1
57
76
58
77
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Fabiano Rosas <farosas@suse.de>
3
IEC binary prefixes ease code review: the unit is explicit.
4
Reviewed-by: Claudio Fontana <cfontana@suse.de>
4
5
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
5
Add the FLASH_SECTOR_SIZE definition.
6
Message-id: 20221213190537.511-6-farosas@suse.de
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-9-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
11
---
9
target/arm/helper.c | 7 -------
12
hw/arm/musicpal.c | 9 ++++++---
10
1 file changed, 7 deletions(-)
13
1 file changed, 6 insertions(+), 3 deletions(-)
11
14
12
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
13
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/helper.c
17
--- a/hw/arm/musicpal.c
15
+++ b/target/arm/helper.c
18
+++ b/hw/arm/musicpal.c
16
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
17
*/
20
*/
18
21
19
#include "qemu/osdep.h"
22
#include "qemu/osdep.h"
20
-#include "qemu/units.h"
23
+#include "qemu/units.h"
21
#include "qemu/log.h"
24
#include "qapi/error.h"
22
#include "trace.h"
23
#include "cpu.h"
25
#include "cpu.h"
24
#include "internals.h"
26
#include "hw/sysbus.h"
25
#include "exec/helper-proto.h"
27
@@ -XXX,XX +XXX,XX @@ static const TypeInfo musicpal_key_info = {
26
-#include "qemu/host-utils.h"
28
.class_init = musicpal_key_class_init,
27
#include "qemu/main-loop.h"
29
};
28
#include "qemu/timer.h"
30
29
#include "qemu/bitops.h"
31
+#define FLASH_SECTOR_SIZE (64 * KiB)
30
@@ -XXX,XX +XXX,XX @@
32
+
31
#include "exec/exec-all.h"
33
static struct arm_boot_info musicpal_binfo = {
32
#include <zlib.h> /* For crc32 */
34
.loader_start = 0x0,
33
#include "hw/irq.h"
35
.board_id = 0x20e,
34
-#include "semihosting/semihost.h"
36
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
35
-#include "sysemu/cpus.h"
37
BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
36
#include "sysemu/cpu-timers.h"
38
37
#include "sysemu/kvm.h"
39
flash_size = blk_getlength(blk);
38
-#include "qemu/range.h"
40
- if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
39
#include "qapi/qapi-commands-machine-target.h"
41
- flash_size != 32*1024*1024) {
40
#include "qapi/error.h"
42
+ if (flash_size != 8 * MiB && flash_size != 16 * MiB &&
41
#include "qemu/guest-random.h"
43
+ flash_size != 32 * MiB) {
42
#ifdef CONFIG_TCG
44
error_report("Invalid flash image size");
43
-#include "arm_ldst.h"
45
exit(1);
44
-#include "exec/cpu_ldst.h"
46
}
45
#include "semihosting/common-semi.h"
47
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
46
#endif
48
*/
47
#include "cpregs.h"
49
pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX,
50
"musicpal.flash", flash_size,
51
- blk, 0x10000,
52
+ blk, FLASH_SECTOR_SIZE,
53
MP_FLASH_SIZE_MAX / flash_size,
54
2, 0x00BF, 0x236D, 0x0000, 0x0000,
55
0x5555, 0x2AAA, 0);
48
--
56
--
49
2.25.1
57
2.34.1
58
59
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
The total_ram_v1/total_ram_v2 definitions were never used.
4
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20230109115316.2235-10-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
10
hw/arm/omap_sx1.c | 2 --
11
1 file changed, 2 deletions(-)
12
13
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
14
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/omap_sx1.c
16
+++ b/hw/arm/omap_sx1.c
17
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps static_ops = {
18
#define flash0_size    (16 * 1024 * 1024)
19
#define flash1_size    ( 8 * 1024 * 1024)
20
#define flash2_size    (32 * 1024 * 1024)
21
-#define total_ram_v1    (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE)
22
-#define total_ram_v2    (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)
23
24
static struct arm_boot_info sx1_binfo = {
25
.loader_start = OMAP_EMIFF_BASE,
26
--
27
2.34.1
28
29
diff view generated by jsdifflib
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The i.MX6UL doesn't support CLK_HIGH ou CLK_HIGH_DIV clock source.
3
IEC binary prefixes ease code review: the unit is explicit.
4
4
5
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20230109115316.2235-11-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
9
---
9
include/hw/timer/imx_gpt.h | 1 +
10
hw/arm/omap_sx1.c | 33 +++++++++++++++++----------------
10
hw/arm/fsl-imx6ul.c | 2 +-
11
1 file changed, 17 insertions(+), 16 deletions(-)
11
hw/misc/imx6ul_ccm.c | 6 ------
12
hw/timer/imx_gpt.c | 25 +++++++++++++++++++++++++
13
4 files changed, 27 insertions(+), 7 deletions(-)
14
12
15
diff --git a/include/hw/timer/imx_gpt.h b/include/hw/timer/imx_gpt.h
13
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
16
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/timer/imx_gpt.h
15
--- a/hw/arm/omap_sx1.c
18
+++ b/include/hw/timer/imx_gpt.h
16
+++ b/hw/arm/omap_sx1.c
19
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@
20
#define TYPE_IMX25_GPT "imx25.gpt"
18
* with this program; if not, see <http://www.gnu.org/licenses/>.
21
#define TYPE_IMX31_GPT "imx31.gpt"
19
*/
22
#define TYPE_IMX6_GPT "imx6.gpt"
20
#include "qemu/osdep.h"
23
+#define TYPE_IMX6UL_GPT "imx6ul.gpt"
21
+#include "qemu/units.h"
24
#define TYPE_IMX7_GPT "imx7.gpt"
22
#include "qapi/error.h"
25
23
#include "ui/console.h"
26
#define TYPE_IMX_GPT TYPE_IMX25_GPT
24
#include "hw/arm/omap.h"
27
diff --git a/hw/arm/fsl-imx6ul.c b/hw/arm/fsl-imx6ul.c
25
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps static_ops = {
28
index XXXXXXX..XXXXXXX 100644
26
.endianness = DEVICE_NATIVE_ENDIAN,
29
--- a/hw/arm/fsl-imx6ul.c
27
};
30
+++ b/hw/arm/fsl-imx6ul.c
28
31
@@ -XXX,XX +XXX,XX @@ static void fsl_imx6ul_init(Object *obj)
29
-#define sdram_size    0x02000000
32
*/
30
-#define sector_size    (128 * 1024)
33
for (i = 0; i < FSL_IMX6UL_NUM_GPTS; i++) {
31
-#define flash0_size    (16 * 1024 * 1024)
34
snprintf(name, NAME_SIZE, "gpt%d", i);
32
-#define flash1_size    ( 8 * 1024 * 1024)
35
- object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX7_GPT);
33
-#define flash2_size    (32 * 1024 * 1024)
36
+ object_initialize_child(obj, name, &s->gpt[i], TYPE_IMX6UL_GPT);
34
+#define SDRAM_SIZE (32 * MiB)
35
+#define SECTOR_SIZE (128 * KiB)
36
+#define FLASH0_SIZE (16 * MiB)
37
+#define FLASH1_SIZE (8 * MiB)
38
+#define FLASH2_SIZE (32 * MiB)
39
40
static struct arm_boot_info sx1_binfo = {
41
.loader_start = OMAP_EMIFF_BASE,
42
- .ram_size = sdram_size,
43
+ .ram_size = SDRAM_SIZE,
44
.board_id = 0x265,
45
};
46
47
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
48
static uint32_t cs3val = 0x00001139;
49
DriveInfo *dinfo;
50
int fl_idx;
51
- uint32_t flash_size = flash0_size;
52
+ uint32_t flash_size = FLASH0_SIZE;
53
54
if (machine->ram_size != mc->default_ram_size) {
55
char *sz = size_to_str(mc->default_ram_size);
56
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
37
}
57
}
38
58
39
/*
59
if (version == 2) {
40
diff --git a/hw/misc/imx6ul_ccm.c b/hw/misc/imx6ul_ccm.c
60
- flash_size = flash2_size;
41
index XXXXXXX..XXXXXXX 100644
61
+ flash_size = FLASH2_SIZE;
42
--- a/hw/misc/imx6ul_ccm.c
62
}
43
+++ b/hw/misc/imx6ul_ccm.c
63
44
@@ -XXX,XX +XXX,XX @@ static uint32_t imx6ul_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
64
memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, machine->ram);
45
case CLK_32k:
65
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
46
freq = CKIL_FREQ;
66
if (!pflash_cfi01_register(OMAP_CS0_BASE,
47
break;
67
"omap_sx1.flash0-1", flash_size,
48
- case CLK_HIGH:
68
blk_by_legacy_dinfo(dinfo),
49
- freq = CKIH_FREQ;
69
- sector_size, 4, 0, 0, 0, 0, 0)) {
50
- break;
70
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
51
- case CLK_HIGH_DIV:
71
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
52
- freq = CKIH_FREQ / 8;
72
fl_idx);
53
- break;
73
}
54
default:
74
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
55
qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: unsupported clock %d\n",
75
(dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
56
TYPE_IMX6UL_CCM, __func__, clock);
76
MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
57
diff --git a/hw/timer/imx_gpt.c b/hw/timer/imx_gpt.c
77
memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0",
58
index XXXXXXX..XXXXXXX 100644
78
- flash1_size, &error_fatal);
59
--- a/hw/timer/imx_gpt.c
79
+ FLASH1_SIZE, &error_fatal);
60
+++ b/hw/timer/imx_gpt.c
80
memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
61
@@ -XXX,XX +XXX,XX @@ static const IMXClk imx6_gpt_clocks[] = {
81
62
CLK_HIGH, /* 111 reference clock */
82
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
63
};
83
- "sx1.cs1", OMAP_CS1_SIZE - flash1_size);
64
84
+ "sx1.cs1", OMAP_CS1_SIZE - FLASH1_SIZE);
65
+static const IMXClk imx6ul_gpt_clocks[] = {
85
memory_region_add_subregion(address_space,
66
+ CLK_NONE, /* 000 No clock source */
86
- OMAP_CS1_BASE + flash1_size, &cs[1]);
67
+ CLK_IPG, /* 001 ipg_clk, 532MHz*/
87
+ OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]);
68
+ CLK_IPG_HIGH, /* 010 ipg_clk_highfreq */
88
69
+ CLK_EXT, /* 011 External clock */
89
if (!pflash_cfi01_register(OMAP_CS1_BASE,
70
+ CLK_32k, /* 100 ipg_clk_32k */
90
- "omap_sx1.flash1-1", flash1_size,
71
+ CLK_NONE, /* 101 not defined */
91
+ "omap_sx1.flash1-1", FLASH1_SIZE,
72
+ CLK_NONE, /* 110 not defined */
92
blk_by_legacy_dinfo(dinfo),
73
+ CLK_NONE, /* 111 not defined */
93
- sector_size, 4, 0, 0, 0, 0, 0)) {
74
+};
94
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
75
+
95
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
76
static const IMXClk imx7_gpt_clocks[] = {
96
fl_idx);
77
CLK_NONE, /* 000 No clock source */
97
}
78
CLK_IPG, /* 001 ipg_clk, 532MHz*/
98
@@ -XXX,XX +XXX,XX @@ static void sx1_machine_v2_class_init(ObjectClass *oc, void *data)
79
@@ -XXX,XX +XXX,XX @@ static void imx6_gpt_init(Object *obj)
99
mc->init = sx1_init_v2;
80
s->clocks = imx6_gpt_clocks;
100
mc->ignore_memory_transaction_failures = true;
101
mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t");
102
- mc->default_ram_size = sdram_size;
103
+ mc->default_ram_size = SDRAM_SIZE;
104
mc->default_ram_id = "omap1.dram";
81
}
105
}
82
106
83
+static void imx6ul_gpt_init(Object *obj)
107
@@ -XXX,XX +XXX,XX @@ static void sx1_machine_v1_class_init(ObjectClass *oc, void *data)
84
+{
108
mc->init = sx1_init_v1;
85
+ IMXGPTState *s = IMX_GPT(obj);
109
mc->ignore_memory_transaction_failures = true;
86
+
110
mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t");
87
+ s->clocks = imx6ul_gpt_clocks;
111
- mc->default_ram_size = sdram_size;
88
+}
112
+ mc->default_ram_size = SDRAM_SIZE;
89
+
113
mc->default_ram_id = "omap1.dram";
90
static void imx7_gpt_init(Object *obj)
91
{
92
IMXGPTState *s = IMX_GPT(obj);
93
@@ -XXX,XX +XXX,XX @@ static const TypeInfo imx6_gpt_info = {
94
.instance_init = imx6_gpt_init,
95
};
96
97
+static const TypeInfo imx6ul_gpt_info = {
98
+ .name = TYPE_IMX6UL_GPT,
99
+ .parent = TYPE_IMX25_GPT,
100
+ .instance_init = imx6ul_gpt_init,
101
+};
102
+
103
static const TypeInfo imx7_gpt_info = {
104
.name = TYPE_IMX7_GPT,
105
.parent = TYPE_IMX25_GPT,
106
@@ -XXX,XX +XXX,XX @@ static void imx_gpt_register_types(void)
107
type_register_static(&imx25_gpt_info);
108
type_register_static(&imx31_gpt_info);
109
type_register_static(&imx6_gpt_info);
110
+ type_register_static(&imx6ul_gpt_info);
111
type_register_static(&imx7_gpt_info);
112
}
114
}
113
115
114
--
116
--
115
2.25.1
117
2.34.1
118
119
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Signed-off-by: Fabiano Rosas <farosas@suse.de>
3
IEC binary prefixes ease code review: the unit is explicit.
4
Reviewed-by: Claudio Fontana <cfontana@suse.de>
4
5
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
5
Add the FLASH_SECTOR_SIZE definition.
6
Message-id: 20221213190537.511-5-farosas@suse.de
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-12-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
11
---
9
target/arm/m_helper.c | 16 ----------------
12
hw/arm/z2.c | 6 ++++--
10
1 file changed, 16 deletions(-)
13
1 file changed, 4 insertions(+), 2 deletions(-)
11
14
12
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
15
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
13
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
14
--- a/target/arm/m_helper.c
17
--- a/hw/arm/z2.c
15
+++ b/target/arm/m_helper.c
18
+++ b/hw/arm/z2.c
16
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
17
*/
20
*/
18
21
19
#include "qemu/osdep.h"
22
#include "qemu/osdep.h"
20
-#include "qemu/units.h"
23
+#include "qemu/units.h"
21
-#include "target/arm/idau.h"
24
#include "hw/arm/pxa.h"
22
-#include "trace.h"
25
#include "hw/arm/boot.h"
23
#include "cpu.h"
26
#include "hw/i2c/i2c.h"
24
#include "internals.h"
27
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aer915_info = {
25
-#include "exec/gdbstub.h"
28
.class_init = aer915_class_init,
26
#include "exec/helper-proto.h"
29
};
27
-#include "qemu/host-utils.h"
30
28
#include "qemu/main-loop.h"
31
+#define FLASH_SECTOR_SIZE (64 * KiB)
29
#include "qemu/bitops.h"
32
+
30
-#include "qemu/crc32c.h"
33
static void z2_init(MachineState *machine)
31
-#include "qemu/qemu-print.h"
34
{
32
#include "qemu/log.h"
35
- uint32_t sector_len = 0x10000;
33
#include "exec/exec-all.h"
36
PXA2xxState *mpu;
34
-#include <zlib.h> /* For crc32 */
37
DriveInfo *dinfo;
35
-#include "semihosting/semihost.h"
38
void *z2_lcd;
36
-#include "sysemu/cpus.h"
39
@@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine)
37
-#include "sysemu/kvm.h"
40
dinfo = drive_get(IF_PFLASH, 0, 0);
38
-#include "qemu/range.h"
41
if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
39
-#include "qapi/qapi-commands-machine-target.h"
42
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
40
-#include "qapi/error.h"
43
- sector_len, 4, 0, 0, 0, 0, 0)) {
41
-#include "qemu/guest-random.h"
44
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
42
#ifdef CONFIG_TCG
45
error_report("Error registering flash memory");
43
-#include "arm_ldst.h"
46
exit(1);
44
#include "exec/cpu_ldst.h"
47
}
45
#include "semihosting/common-semi.h"
46
#endif
47
--
48
--
48
2.25.1
49
2.34.1
50
51
diff view generated by jsdifflib
1
From: Jean-Christophe Dubois <jcd@tribudubois.net>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
So far the GPT timers were unable to raise IRQs to the processor.
3
Upon introduction in commit b8433303fb ("Set proper device-width
4
for vexpress flash"), ve_pflash_cfi01_register() was calling
5
qdev_init_nofail() which can not fail. This call was later
6
converted with a script to use &error_fatal, still unable to
7
fail. Remove the unreachable code.
4
8
5
Signed-off-by: Jean-Christophe Dubois <jcd@tribudubois.net>
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20230109115316.2235-13-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
13
---
9
include/hw/arm/fsl-imx7.h | 5 +++++
14
hw/arm/vexpress.c | 10 +---------
10
hw/arm/fsl-imx7.c | 10 ++++++++++
15
1 file changed, 1 insertion(+), 9 deletions(-)
11
2 files changed, 15 insertions(+)
12
16
13
diff --git a/include/hw/arm/fsl-imx7.h b/include/hw/arm/fsl-imx7.h
17
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
14
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
15
--- a/include/hw/arm/fsl-imx7.h
19
--- a/hw/arm/vexpress.c
16
+++ b/include/hw/arm/fsl-imx7.h
20
+++ b/hw/arm/vexpress.c
17
@@ -XXX,XX +XXX,XX @@ enum FslIMX7IRQs {
21
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
18
FSL_IMX7_USB2_IRQ = 42,
22
dinfo = drive_get(IF_PFLASH, 0, 0);
19
FSL_IMX7_USB3_IRQ = 40,
23
pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0",
20
24
dinfo);
21
+ FSL_IMX7_GPT1_IRQ = 55,
25
- if (!pflash0) {
22
+ FSL_IMX7_GPT2_IRQ = 54,
26
- error_report("vexpress: error registering flash 0");
23
+ FSL_IMX7_GPT3_IRQ = 53,
27
- exit(1);
24
+ FSL_IMX7_GPT4_IRQ = 52,
28
- }
25
+
29
26
FSL_IMX7_WDOG1_IRQ = 78,
30
if (map[VE_NORFLASHALIAS] != -1) {
27
FSL_IMX7_WDOG2_IRQ = 79,
31
/* Map flash 0 as an alias into low memory */
28
FSL_IMX7_WDOG3_IRQ = 10,
32
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
29
diff --git a/hw/arm/fsl-imx7.c b/hw/arm/fsl-imx7.c
30
index XXXXXXX..XXXXXXX 100644
31
--- a/hw/arm/fsl-imx7.c
32
+++ b/hw/arm/fsl-imx7.c
33
@@ -XXX,XX +XXX,XX @@ static void fsl_imx7_realize(DeviceState *dev, Error **errp)
34
FSL_IMX7_GPT4_ADDR,
35
};
36
37
+ static const int FSL_IMX7_GPTn_IRQ[FSL_IMX7_NUM_GPTS] = {
38
+ FSL_IMX7_GPT1_IRQ,
39
+ FSL_IMX7_GPT2_IRQ,
40
+ FSL_IMX7_GPT3_IRQ,
41
+ FSL_IMX7_GPT4_IRQ,
42
+ };
43
+
44
s->gpt[i].ccm = IMX_CCM(&s->ccm);
45
sysbus_realize(SYS_BUS_DEVICE(&s->gpt[i]), &error_abort);
46
sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpt[i]), 0, FSL_IMX7_GPTn_ADDR[i]);
47
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpt[i]), 0,
48
+ qdev_get_gpio_in(DEVICE(&s->a7mpcore),
49
+ FSL_IMX7_GPTn_IRQ[i]));
50
}
33
}
51
34
52
for (i = 0; i < FSL_IMX7_NUM_GPIOS; i++) {
35
dinfo = drive_get(IF_PFLASH, 0, 1);
36
- if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1",
37
- dinfo)) {
38
- error_report("vexpress: error registering flash 1");
39
- exit(1);
40
- }
41
+ ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo);
42
43
sram_size = 0x2000000;
44
memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size,
53
--
45
--
54
2.25.1
46
2.34.1
47
48
diff view generated by jsdifflib
1
From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
RVBAR shadows RVBAR_ELx where x is the highest exception
3
Since its QOM'ification in commit 368a354f02 ("pflash_cfi0x:
4
level if the highest EL is not EL3. This patch also allows
4
QOMified") the pflash_cfi01_register() function does not fail.
5
ARMv8 CPUs to change the reset address with
6
the rvbar property.
7
5
8
Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
6
This call was later converted with a script to use &error_fatal,
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
still unable to fail. Remove the unreachable code.
10
Message-id: 20221206102504.165775-3-tobias.roehmel@rwth-aachen.de
8
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Message-id: 20230109115316.2235-14-philmd@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
---
13
target/arm/cpu.c | 6 +++++-
14
hw/arm/gumstix.c | 18 ++++++------------
14
target/arm/helper.c | 21 ++++++++++++++-------
15
hw/arm/mainstone.c | 13 +++++--------
15
2 files changed, 19 insertions(+), 8 deletions(-)
16
hw/arm/omap_sx1.c | 22 ++++++++--------------
17
hw/arm/versatilepb.c | 6 ++----
18
hw/arm/z2.c | 9 +++------
19
5 files changed, 24 insertions(+), 44 deletions(-)
16
20
17
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
21
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
18
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
19
--- a/target/arm/cpu.c
23
--- a/hw/arm/gumstix.c
20
+++ b/target/arm/cpu.c
24
+++ b/hw/arm/gumstix.c
21
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_reset_hold(Object *obj)
25
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
22
env->cp15.cpacr_el1 = FIELD_DP64(env->cp15.cpacr_el1,
23
CPACR, CP11, 3);
24
#endif
25
+ if (arm_feature(env, ARM_FEATURE_V8)) {
26
+ env->cp15.rvbar = cpu->rvbar_prop;
27
+ env->regs[15] = cpu->rvbar_prop;
28
+ }
29
}
26
}
30
27
31
#if defined(CONFIG_USER_ONLY)
28
/* Numonyx RC28F128J3F75 */
32
@@ -XXX,XX +XXX,XX @@ void arm_cpu_post_init(Object *obj)
29
- if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
33
qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_hivecs_property);
30
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
31
- FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
32
- error_report("Error registering flash memory");
33
- exit(1);
34
- }
35
+ pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
36
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
37
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0);
38
39
/* Interrupt line of NIC is connected to GPIO line 36 */
40
smc91c111_init(&nd_table[0], 0x04000300,
41
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
34
}
42
}
35
43
36
- if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
44
/* Micron RC28F256P30TFA */
37
+ if (arm_feature(&cpu->env, ARM_FEATURE_V8)) {
45
- if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
38
object_property_add_uint64_ptr(obj, "rvbar",
46
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
39
&cpu->rvbar_prop,
47
- FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
40
OBJ_PROP_FLAG_READWRITE);
48
- error_report("Error registering flash memory");
41
diff --git a/target/arm/helper.c b/target/arm/helper.c
49
- exit(1);
50
- }
51
+ pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
52
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
53
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0);
54
55
/* Interrupt line of NIC is connected to GPIO line 99 */
56
smc91c111_init(&nd_table[0], 0x04000300,
57
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
42
index XXXXXXX..XXXXXXX 100644
58
index XXXXXXX..XXXXXXX 100644
43
--- a/target/arm/helper.c
59
--- a/hw/arm/mainstone.c
44
+++ b/target/arm/helper.c
60
+++ b/hw/arm/mainstone.c
45
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
61
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine,
46
if (!arm_feature(env, ARM_FEATURE_EL3) &&
62
/* There are two 32MiB flash devices on the board */
47
!arm_feature(env, ARM_FEATURE_EL2)) {
63
for (i = 0; i < 2; i ++) {
48
ARMCPRegInfo rvbar = {
64
dinfo = drive_get(IF_PFLASH, 0, i);
49
- .name = "RVBAR_EL1", .state = ARM_CP_STATE_AA64,
65
- if (!pflash_cfi01_register(mainstone_flash_base[i],
50
+ .name = "RVBAR_EL1", .state = ARM_CP_STATE_BOTH,
66
- i ? "mainstone.flash1" : "mainstone.flash0",
51
.opc0 = 3, .opc1 = 0, .crn = 12, .crm = 0, .opc2 = 1,
67
- MAINSTONE_FLASH_SIZE,
52
.access = PL1_R,
68
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
53
.fieldoffset = offsetof(CPUARMState, cp15.rvbar),
69
- FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
54
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
70
- error_report("Error registering flash memory");
55
}
71
- exit(1);
56
/* RVBAR_EL2 is only implemented if EL2 is the highest EL */
72
- }
57
if (!arm_feature(env, ARM_FEATURE_EL3)) {
73
+ pflash_cfi01_register(mainstone_flash_base[i],
58
- ARMCPRegInfo rvbar = {
74
+ i ? "mainstone.flash1" : "mainstone.flash0",
59
- .name = "RVBAR_EL2", .state = ARM_CP_STATE_AA64,
75
+ MAINSTONE_FLASH_SIZE,
60
- .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 1,
76
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
61
- .access = PL2_R,
77
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
62
- .fieldoffset = offsetof(CPUARMState, cp15.rvbar),
63
+ ARMCPRegInfo rvbar[] = {
64
+ {
65
+ .name = "RVBAR_EL2", .state = ARM_CP_STATE_AA64,
66
+ .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 1,
67
+ .access = PL2_R,
68
+ .fieldoffset = offsetof(CPUARMState, cp15.rvbar),
69
+ },
70
+ { .name = "RVBAR", .type = ARM_CP_ALIAS,
71
+ .cp = 15, .opc1 = 0, .crn = 12, .crm = 0, .opc2 = 1,
72
+ .access = PL2_R,
73
+ .fieldoffset = offsetof(CPUARMState, cp15.rvbar),
74
+ },
75
};
76
- define_one_arm_cp_reg(cpu, &rvbar);
77
+ define_arm_cp_regs(cpu, rvbar);
78
}
79
}
78
}
80
79
80
mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
81
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
82
index XXXXXXX..XXXXXXX 100644
83
--- a/hw/arm/omap_sx1.c
84
+++ b/hw/arm/omap_sx1.c
85
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
86
87
fl_idx = 0;
88
if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
89
- if (!pflash_cfi01_register(OMAP_CS0_BASE,
90
- "omap_sx1.flash0-1", flash_size,
91
- blk_by_legacy_dinfo(dinfo),
92
- SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
93
- fprintf(stderr, "qemu: Error registering flash memory %d.\n",
94
- fl_idx);
95
- }
96
+ pflash_cfi01_register(OMAP_CS0_BASE,
97
+ "omap_sx1.flash0-1", flash_size,
98
+ blk_by_legacy_dinfo(dinfo),
99
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
100
fl_idx++;
101
}
102
103
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
104
memory_region_add_subregion(address_space,
105
OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]);
106
107
- if (!pflash_cfi01_register(OMAP_CS1_BASE,
108
- "omap_sx1.flash1-1", FLASH1_SIZE,
109
- blk_by_legacy_dinfo(dinfo),
110
- SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
111
- fprintf(stderr, "qemu: Error registering flash memory %d.\n",
112
- fl_idx);
113
- }
114
+ pflash_cfi01_register(OMAP_CS1_BASE,
115
+ "omap_sx1.flash1-1", FLASH1_SIZE,
116
+ blk_by_legacy_dinfo(dinfo),
117
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
118
fl_idx++;
119
} else {
120
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
121
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
122
index XXXXXXX..XXXXXXX 100644
123
--- a/hw/arm/versatilepb.c
124
+++ b/hw/arm/versatilepb.c
125
@@ -XXX,XX +XXX,XX @@ static void versatile_init(MachineState *machine, int board_id)
126
/* 0x34000000 NOR Flash */
127
128
dinfo = drive_get(IF_PFLASH, 0, 0);
129
- if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash",
130
+ pflash_cfi01_register(VERSATILE_FLASH_ADDR, "versatile.flash",
131
VERSATILE_FLASH_SIZE,
132
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
133
VERSATILE_FLASH_SECT_SIZE,
134
- 4, 0x0089, 0x0018, 0x0000, 0x0, 0)) {
135
- fprintf(stderr, "qemu: Error registering flash memory.\n");
136
- }
137
+ 4, 0x0089, 0x0018, 0x0000, 0x0, 0);
138
139
versatile_binfo.ram_size = machine->ram_size;
140
versatile_binfo.board_id = board_id;
141
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
142
index XXXXXXX..XXXXXXX 100644
143
--- a/hw/arm/z2.c
144
+++ b/hw/arm/z2.c
145
@@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine)
146
mpu = pxa270_init(z2_binfo.ram_size, machine->cpu_type);
147
148
dinfo = drive_get(IF_PFLASH, 0, 0);
149
- if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
150
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
151
- FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
152
- error_report("Error registering flash memory");
153
- exit(1);
154
- }
155
+ pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
156
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
157
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
158
159
/* setup keypad */
160
pxa27x_register_keypad(mpu->kp, map, 0x100);
81
--
161
--
82
2.25.1
162
2.34.1
83
163
84
164
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
To avoid forward-declaring PXA2xxI2CState, declare
4
PXA2XX_I2C before its use in pxa2xx_i2c_init() prototype.
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230109140306.23161-2-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
include/hw/arm/pxa.h | 6 +++---
12
1 file changed, 3 insertions(+), 3 deletions(-)
13
14
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
15
index XXXXXXX..XXXXXXX 100644
16
--- a/include/hw/arm/pxa.h
17
+++ b/include/hw/arm/pxa.h
18
@@ -XXX,XX +XXX,XX @@ void pxa27x_register_keypad(PXA2xxKeyPadState *kp,
19
const struct keymap *map, int size);
20
21
/* pxa2xx.c */
22
-typedef struct PXA2xxI2CState PXA2xxI2CState;
23
+#define TYPE_PXA2XX_I2C "pxa2xx_i2c"
24
+OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxI2CState, PXA2XX_I2C)
25
+
26
PXA2xxI2CState *pxa2xx_i2c_init(hwaddr base,
27
qemu_irq irq, uint32_t page_size);
28
I2CBus *pxa2xx_i2c_bus(PXA2xxI2CState *s);
29
30
-#define TYPE_PXA2XX_I2C "pxa2xx_i2c"
31
typedef struct PXA2xxI2SState PXA2xxI2SState;
32
-OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxI2CState, PXA2XX_I2C)
33
34
#define TYPE_PXA2XX_FIR "pxa2xx-fir"
35
OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxFIrState, PXA2XX_FIR)
36
--
37
2.34.1
38
39
diff view generated by jsdifflib
New patch
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
2
3
Add a local 'struct omap_gpif_s *' variable to improve readability.
4
(This also eases next commit conversion).
5
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20230109140306.23161-3-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
hw/gpio/omap_gpio.c | 3 ++-
12
1 file changed, 2 insertions(+), 1 deletion(-)
13
14
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/gpio/omap_gpio.c
17
+++ b/hw/gpio/omap_gpio.c
18
@@ -XXX,XX +XXX,XX @@ struct omap_gpif_s {
19
/* General-Purpose I/O of OMAP1 */
20
static void omap_gpio_set(void *opaque, int line, int level)
21
{
22
- struct omap_gpio_s *s = &((struct omap_gpif_s *) opaque)->omap1;
23
+ struct omap_gpif_s *p = opaque;
24
+ struct omap_gpio_s *s = &p->omap1;
25
uint16_t prev = s->inputs;
26
27
if (level)
28
--
29
2.34.1
30
31
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Fix the following:
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
ERROR: spaces required around that '|' (ctx:VxV)
5
Message-id: 20230109140306.23161-4-philmd@linaro.org
6
ERROR: space required before the open parenthesis '('
7
ERROR: spaces required around that '+' (ctx:VxB)
8
ERROR: space prohibited between function name and open parenthesis '('
9
10
(the last two still have some occurrences in macros which I left
11
behind because it might impact readability)
12
13
Signed-off-by: Fabiano Rosas <farosas@suse.de>
14
Reviewed-by: Claudio Fontana <cfontana@suse.de>
15
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
16
Message-id: 20221213190537.511-3-farosas@suse.de
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
7
---
19
target/arm/helper.c | 42 +++++++++++++++++++++---------------------
8
hw/arm/omap1.c | 115 ++++++++++++++++++--------------------
20
1 file changed, 21 insertions(+), 21 deletions(-)
9
hw/arm/omap2.c | 40 ++++++-------
10
hw/arm/omap_sx1.c | 2 +-
11
hw/arm/palm.c | 2 +-
12
hw/char/omap_uart.c | 7 +--
13
hw/display/omap_dss.c | 15 +++--
14
hw/display/omap_lcdc.c | 9 ++-
15
hw/dma/omap_dma.c | 15 +++--
16
hw/gpio/omap_gpio.c | 15 +++--
17
hw/intc/omap_intc.c | 12 ++--
18
hw/misc/omap_gpmc.c | 12 ++--
19
hw/misc/omap_l4.c | 7 +--
20
hw/misc/omap_sdrc.c | 7 +--
21
hw/misc/omap_tap.c | 5 +-
22
hw/sd/omap_mmc.c | 9 ++-
23
hw/ssi/omap_spi.c | 7 +--
24
hw/timer/omap_gptimer.c | 22 ++++----
25
hw/timer/omap_synctimer.c | 4 +-
26
18 files changed, 142 insertions(+), 163 deletions(-)
21
27
22
diff --git a/target/arm/helper.c b/target/arm/helper.c
28
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
23
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
24
--- a/target/arm/helper.c
30
--- a/hw/arm/omap1.c
25
+++ b/target/arm/helper.c
31
+++ b/hw/arm/omap1.c
26
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_list(gpointer key, gpointer opaque)
32
@@ -XXX,XX +XXX,XX @@ static void omap_timer_fire(void *opaque)
27
uint32_t regidx = (uintptr_t)key;
33
28
const ARMCPRegInfo *ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
34
static void omap_timer_tick(void *opaque)
29
35
{
30
- if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) {
36
- struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque;
31
+ if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) {
37
+ struct omap_mpu_timer_s *timer = opaque;
32
cpu->cpreg_indexes[cpu->cpreg_array_len] = cpreg_to_kvm_id(regidx);
38
33
/* The value array need not be initialized at this point */
39
omap_timer_sync(timer);
34
cpu->cpreg_array_len++;
40
omap_timer_fire(timer);
35
@@ -XXX,XX +XXX,XX @@ static void count_cpreg(gpointer key, gpointer opaque)
41
@@ -XXX,XX +XXX,XX @@ static void omap_timer_tick(void *opaque)
36
42
37
ri = g_hash_table_lookup(cpu->cp_regs, key);
43
static void omap_timer_clk_update(void *opaque, int line, int on)
38
44
{
39
- if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) {
45
- struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque;
40
+ if (!(ri->type & (ARM_CP_NO_RAW | ARM_CP_ALIAS))) {
46
+ struct omap_mpu_timer_s *timer = opaque;
41
cpu->cpreg_array_len++;
47
48
omap_timer_sync(timer);
49
timer->rate = on ? omap_clk_getrate(timer->clk) : 0;
50
@@ -XXX,XX +XXX,XX @@ static void omap_timer_clk_setup(struct omap_mpu_timer_s *timer)
51
static uint64_t omap_mpu_timer_read(void *opaque, hwaddr addr,
52
unsigned size)
53
{
54
- struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque;
55
+ struct omap_mpu_timer_s *s = opaque;
56
57
if (size != 4) {
58
return omap_badwidth_read32(opaque, addr);
59
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpu_timer_read(void *opaque, hwaddr addr,
60
static void omap_mpu_timer_write(void *opaque, hwaddr addr,
61
uint64_t value, unsigned size)
62
{
63
- struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque;
64
+ struct omap_mpu_timer_s *s = opaque;
65
66
if (size != 4) {
67
omap_badwidth_write32(opaque, addr, value);
68
@@ -XXX,XX +XXX,XX @@ struct omap_watchdog_timer_s {
69
static uint64_t omap_wd_timer_read(void *opaque, hwaddr addr,
70
unsigned size)
71
{
72
- struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque;
73
+ struct omap_watchdog_timer_s *s = opaque;
74
75
if (size != 2) {
76
return omap_badwidth_read16(opaque, addr);
77
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_wd_timer_read(void *opaque, hwaddr addr,
78
static void omap_wd_timer_write(void *opaque, hwaddr addr,
79
uint64_t value, unsigned size)
80
{
81
- struct omap_watchdog_timer_s *s = (struct omap_watchdog_timer_s *) opaque;
82
+ struct omap_watchdog_timer_s *s = opaque;
83
84
if (size != 2) {
85
omap_badwidth_write16(opaque, addr, value);
86
@@ -XXX,XX +XXX,XX @@ struct omap_32khz_timer_s {
87
static uint64_t omap_os_timer_read(void *opaque, hwaddr addr,
88
unsigned size)
89
{
90
- struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque;
91
+ struct omap_32khz_timer_s *s = opaque;
92
int offset = addr & OMAP_MPUI_REG_MASK;
93
94
if (size != 4) {
95
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_os_timer_read(void *opaque, hwaddr addr,
96
static void omap_os_timer_write(void *opaque, hwaddr addr,
97
uint64_t value, unsigned size)
98
{
99
- struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque;
100
+ struct omap_32khz_timer_s *s = opaque;
101
int offset = addr & OMAP_MPUI_REG_MASK;
102
103
if (size != 4) {
104
@@ -XXX,XX +XXX,XX @@ static struct omap_32khz_timer_s *omap_os_timer_init(MemoryRegion *memory,
105
static uint64_t omap_ulpd_pm_read(void *opaque, hwaddr addr,
106
unsigned size)
107
{
108
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
109
+ struct omap_mpu_state_s *s = opaque;
110
uint16_t ret;
111
112
if (size != 2) {
113
@@ -XXX,XX +XXX,XX @@ static inline void omap_ulpd_req_update(struct omap_mpu_state_s *s,
114
static void omap_ulpd_pm_write(void *opaque, hwaddr addr,
115
uint64_t value, unsigned size)
116
{
117
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
118
+ struct omap_mpu_state_s *s = opaque;
119
int64_t now, ticks;
120
int div, mult;
121
static const int bypass_div[4] = { 1, 2, 4, 4 };
122
@@ -XXX,XX +XXX,XX @@ static void omap_ulpd_pm_init(MemoryRegion *system_memory,
123
static uint64_t omap_pin_cfg_read(void *opaque, hwaddr addr,
124
unsigned size)
125
{
126
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
127
+ struct omap_mpu_state_s *s = opaque;
128
129
if (size != 4) {
130
return omap_badwidth_read32(opaque, addr);
131
@@ -XXX,XX +XXX,XX @@ static inline void omap_pin_modconf1_update(struct omap_mpu_state_s *s,
132
static void omap_pin_cfg_write(void *opaque, hwaddr addr,
133
uint64_t value, unsigned size)
134
{
135
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
136
+ struct omap_mpu_state_s *s = opaque;
137
uint32_t diff;
138
139
if (size != 4) {
140
@@ -XXX,XX +XXX,XX @@ static void omap_pin_cfg_init(MemoryRegion *system_memory,
141
static uint64_t omap_id_read(void *opaque, hwaddr addr,
142
unsigned size)
143
{
144
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
145
+ struct omap_mpu_state_s *s = opaque;
146
147
if (size != 4) {
148
return omap_badwidth_read32(opaque, addr);
149
@@ -XXX,XX +XXX,XX @@ static void omap_id_init(MemoryRegion *memory, struct omap_mpu_state_s *mpu)
150
static uint64_t omap_mpui_read(void *opaque, hwaddr addr,
151
unsigned size)
152
{
153
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
154
+ struct omap_mpu_state_s *s = opaque;
155
156
if (size != 4) {
157
return omap_badwidth_read32(opaque, addr);
158
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpui_read(void *opaque, hwaddr addr,
159
static void omap_mpui_write(void *opaque, hwaddr addr,
160
uint64_t value, unsigned size)
161
{
162
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
163
+ struct omap_mpu_state_s *s = opaque;
164
165
if (size != 4) {
166
omap_badwidth_write32(opaque, addr, value);
167
@@ -XXX,XX +XXX,XX @@ struct omap_tipb_bridge_s {
168
static uint64_t omap_tipb_bridge_read(void *opaque, hwaddr addr,
169
unsigned size)
170
{
171
- struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque;
172
+ struct omap_tipb_bridge_s *s = opaque;
173
174
if (size < 2) {
175
return omap_badwidth_read16(opaque, addr);
176
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_tipb_bridge_read(void *opaque, hwaddr addr,
177
static void omap_tipb_bridge_write(void *opaque, hwaddr addr,
178
uint64_t value, unsigned size)
179
{
180
- struct omap_tipb_bridge_s *s = (struct omap_tipb_bridge_s *) opaque;
181
+ struct omap_tipb_bridge_s *s = opaque;
182
183
if (size < 2) {
184
omap_badwidth_write16(opaque, addr, value);
185
@@ -XXX,XX +XXX,XX @@ static struct omap_tipb_bridge_s *omap_tipb_bridge_init(
186
static uint64_t omap_tcmi_read(void *opaque, hwaddr addr,
187
unsigned size)
188
{
189
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
190
+ struct omap_mpu_state_s *s = opaque;
191
uint32_t ret;
192
193
if (size != 4) {
194
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_tcmi_read(void *opaque, hwaddr addr,
195
static void omap_tcmi_write(void *opaque, hwaddr addr,
196
uint64_t value, unsigned size)
197
{
198
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
199
+ struct omap_mpu_state_s *s = opaque;
200
201
if (size != 4) {
202
omap_badwidth_write32(opaque, addr, value);
203
@@ -XXX,XX +XXX,XX @@ struct dpll_ctl_s {
204
static uint64_t omap_dpll_read(void *opaque, hwaddr addr,
205
unsigned size)
206
{
207
- struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque;
208
+ struct dpll_ctl_s *s = opaque;
209
210
if (size != 2) {
211
return omap_badwidth_read16(opaque, addr);
212
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_dpll_read(void *opaque, hwaddr addr,
213
static void omap_dpll_write(void *opaque, hwaddr addr,
214
uint64_t value, unsigned size)
215
{
216
- struct dpll_ctl_s *s = (struct dpll_ctl_s *) opaque;
217
+ struct dpll_ctl_s *s = opaque;
218
uint16_t diff;
219
static const int bypass_div[4] = { 1, 2, 4, 4 };
220
int div, mult;
221
@@ -XXX,XX +XXX,XX @@ static struct dpll_ctl_s *omap_dpll_init(MemoryRegion *memory,
222
static uint64_t omap_clkm_read(void *opaque, hwaddr addr,
223
unsigned size)
224
{
225
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
226
+ struct omap_mpu_state_s *s = opaque;
227
228
if (size != 2) {
229
return omap_badwidth_read16(opaque, addr);
230
@@ -XXX,XX +XXX,XX @@ static inline void omap_clkm_ckout1_update(struct omap_mpu_state_s *s,
231
static void omap_clkm_write(void *opaque, hwaddr addr,
232
uint64_t value, unsigned size)
233
{
234
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
235
+ struct omap_mpu_state_s *s = opaque;
236
uint16_t diff;
237
omap_clk clk;
238
static const char *clkschemename[8] = {
239
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_clkm_ops = {
240
static uint64_t omap_clkdsp_read(void *opaque, hwaddr addr,
241
unsigned size)
242
{
243
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
244
+ struct omap_mpu_state_s *s = opaque;
245
CPUState *cpu = CPU(s->cpu);
246
247
if (size != 2) {
248
@@ -XXX,XX +XXX,XX @@ static inline void omap_clkdsp_idlect2_update(struct omap_mpu_state_s *s,
249
static void omap_clkdsp_write(void *opaque, hwaddr addr,
250
uint64_t value, unsigned size)
251
{
252
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
253
+ struct omap_mpu_state_s *s = opaque;
254
uint16_t diff;
255
256
if (size != 2) {
257
@@ -XXX,XX +XXX,XX @@ struct omap_mpuio_s {
258
259
static void omap_mpuio_set(void *opaque, int line, int level)
260
{
261
- struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque;
262
+ struct omap_mpuio_s *s = opaque;
263
uint16_t prev = s->inputs;
264
265
if (level)
266
@@ -XXX,XX +XXX,XX @@ static void omap_mpuio_kbd_update(struct omap_mpuio_s *s)
267
static uint64_t omap_mpuio_read(void *opaque, hwaddr addr,
268
unsigned size)
269
{
270
- struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque;
271
+ struct omap_mpuio_s *s = opaque;
272
int offset = addr & OMAP_MPUI_REG_MASK;
273
uint16_t ret;
274
275
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mpuio_read(void *opaque, hwaddr addr,
276
static void omap_mpuio_write(void *opaque, hwaddr addr,
277
uint64_t value, unsigned size)
278
{
279
- struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque;
280
+ struct omap_mpuio_s *s = opaque;
281
int offset = addr & OMAP_MPUI_REG_MASK;
282
uint16_t diff;
283
int ln;
284
@@ -XXX,XX +XXX,XX @@ static void omap_mpuio_reset(struct omap_mpuio_s *s)
285
286
static void omap_mpuio_onoff(void *opaque, int line, int on)
287
{
288
- struct omap_mpuio_s *s = (struct omap_mpuio_s *) opaque;
289
+ struct omap_mpuio_s *s = opaque;
290
291
s->clk = on;
292
if (on)
293
@@ -XXX,XX +XXX,XX @@ static void omap_uwire_transfer_start(struct omap_uwire_s *s)
42
}
294
}
43
}
295
}
44
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = {
296
45
.resetfn = arm_cp_reset_ignore },
297
-static uint64_t omap_uwire_read(void *opaque, hwaddr addr,
46
{ .name = "TPIDRRO_EL0", .state = ARM_CP_STATE_AA64,
298
- unsigned size)
47
.opc0 = 3, .opc1 = 3, .opc2 = 3, .crn = 13, .crm = 0,
299
+static uint64_t omap_uwire_read(void *opaque, hwaddr addr, unsigned size)
48
- .access = PL0_R|PL1_W,
300
{
49
+ .access = PL0_R | PL1_W,
301
- struct omap_uwire_s *s = (struct omap_uwire_s *) opaque;
50
.fieldoffset = offsetof(CPUARMState, cp15.tpidrro_el[0]),
302
+ struct omap_uwire_s *s = opaque;
51
.resetvalue = 0},
303
int offset = addr & OMAP_MPUI_REG_MASK;
52
{ .name = "TPIDRURO", .cp = 15, .crn = 13, .crm = 0, .opc1 = 0, .opc2 = 3,
304
53
- .access = PL0_R|PL1_W,
305
if (size != 2) {
54
+ .access = PL0_R | PL1_W,
306
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_uwire_read(void *opaque, hwaddr addr,
55
.bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.tpidruro_s),
307
static void omap_uwire_write(void *opaque, hwaddr addr,
56
offsetoflow32(CPUARMState, cp15.tpidruro_ns) },
308
uint64_t value, unsigned size)
57
.resetfn = arm_cp_reset_ignore },
309
{
58
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = {
310
- struct omap_uwire_s *s = (struct omap_uwire_s *) opaque;
59
.resetvalue = 0 },
311
+ struct omap_uwire_s *s = opaque;
60
/* The cache ops themselves: these all NOP for QEMU */
312
int offset = addr & OMAP_MPUI_REG_MASK;
61
{ .name = "IICR", .cp = 15, .crm = 5, .opc1 = 0,
313
62
- .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT },
314
if (size != 2) {
63
+ .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT },
315
@@ -XXX,XX +XXX,XX @@ static void omap_pwl_update(struct omap_pwl_s *s)
64
{ .name = "IDCR", .cp = 15, .crm = 6, .opc1 = 0,
316
}
65
- .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT },
317
}
66
+ .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT },
318
67
{ .name = "CDCR", .cp = 15, .crm = 12, .opc1 = 0,
319
-static uint64_t omap_pwl_read(void *opaque, hwaddr addr,
68
- .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT },
320
- unsigned size)
69
+ .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT },
321
+static uint64_t omap_pwl_read(void *opaque, hwaddr addr, unsigned size)
70
{ .name = "PIR", .cp = 15, .crm = 12, .opc1 = 1,
322
{
71
- .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT },
323
- struct omap_pwl_s *s = (struct omap_pwl_s *) opaque;
72
+ .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT },
324
+ struct omap_pwl_s *s = opaque;
73
{ .name = "PDR", .cp = 15, .crm = 12, .opc1 = 2,
325
int offset = addr & OMAP_MPUI_REG_MASK;
74
- .access = PL0_W, .type = ARM_CP_NOP|ARM_CP_64BIT },
326
75
+ .access = PL0_W, .type = ARM_CP_NOP | ARM_CP_64BIT },
327
if (size != 1) {
76
{ .name = "CIDCR", .cp = 15, .crm = 14, .opc1 = 0,
328
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_pwl_read(void *opaque, hwaddr addr,
77
- .access = PL1_W, .type = ARM_CP_NOP|ARM_CP_64BIT },
329
static void omap_pwl_write(void *opaque, hwaddr addr,
78
+ .access = PL1_W, .type = ARM_CP_NOP | ARM_CP_64BIT },
330
uint64_t value, unsigned size)
331
{
332
- struct omap_pwl_s *s = (struct omap_pwl_s *) opaque;
333
+ struct omap_pwl_s *s = opaque;
334
int offset = addr & OMAP_MPUI_REG_MASK;
335
336
if (size != 1) {
337
@@ -XXX,XX +XXX,XX @@ static void omap_pwl_reset(struct omap_pwl_s *s)
338
339
static void omap_pwl_clk_update(void *opaque, int line, int on)
340
{
341
- struct omap_pwl_s *s = (struct omap_pwl_s *) opaque;
342
+ struct omap_pwl_s *s = opaque;
343
344
s->clk = on;
345
omap_pwl_update(s);
346
@@ -XXX,XX +XXX,XX @@ struct omap_pwt_s {
347
omap_clk clk;
79
};
348
};
80
349
81
static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = {
350
-static uint64_t omap_pwt_read(void *opaque, hwaddr addr,
82
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
351
- unsigned size)
83
ARMCPRegInfo cbar = {
352
+static uint64_t omap_pwt_read(void *opaque, hwaddr addr, unsigned size)
84
.name = "CBAR",
353
{
85
.cp = 15, .crn = 15, .crm = 0, .opc1 = 4, .opc2 = 0,
354
- struct omap_pwt_s *s = (struct omap_pwt_s *) opaque;
86
- .access = PL1_R|PL3_W, .resetvalue = cpu->reset_cbar,
355
+ struct omap_pwt_s *s = opaque;
87
+ .access = PL1_R | PL3_W, .resetvalue = cpu->reset_cbar,
356
int offset = addr & OMAP_MPUI_REG_MASK;
88
.fieldoffset = offsetof(CPUARMState,
357
89
cp15.c15_config_base_address)
358
if (size != 1) {
90
};
359
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_pwt_read(void *opaque, hwaddr addr,
91
@@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode)
360
static void omap_pwt_write(void *opaque, hwaddr addr,
92
return;
361
uint64_t value, unsigned size)
93
362
{
94
if (old_mode == ARM_CPU_MODE_FIQ) {
363
- struct omap_pwt_s *s = (struct omap_pwt_s *) opaque;
95
- memcpy (env->fiq_regs, env->regs + 8, 5 * sizeof(uint32_t));
364
+ struct omap_pwt_s *s = opaque;
96
- memcpy (env->regs + 8, env->usr_regs, 5 * sizeof(uint32_t));
365
int offset = addr & OMAP_MPUI_REG_MASK;
97
+ memcpy(env->fiq_regs, env->regs + 8, 5 * sizeof(uint32_t));
366
98
+ memcpy(env->regs + 8, env->usr_regs, 5 * sizeof(uint32_t));
367
if (size != 1) {
99
} else if (mode == ARM_CPU_MODE_FIQ) {
368
@@ -XXX,XX +XXX,XX @@ static void omap_rtc_alarm_update(struct omap_rtc_s *s)
100
- memcpy (env->usr_regs, env->regs + 8, 5 * sizeof(uint32_t));
369
printf("%s: conversion failed\n", __func__);
101
- memcpy (env->regs + 8, env->fiq_regs, 5 * sizeof(uint32_t));
370
}
102
+ memcpy(env->usr_regs, env->regs + 8, 5 * sizeof(uint32_t));
371
103
+ memcpy(env->regs + 8, env->fiq_regs, 5 * sizeof(uint32_t));
372
-static uint64_t omap_rtc_read(void *opaque, hwaddr addr,
373
- unsigned size)
374
+static uint64_t omap_rtc_read(void *opaque, hwaddr addr, unsigned size)
375
{
376
- struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
377
+ struct omap_rtc_s *s = opaque;
378
int offset = addr & OMAP_MPUI_REG_MASK;
379
uint8_t i;
380
381
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_rtc_read(void *opaque, hwaddr addr,
382
static void omap_rtc_write(void *opaque, hwaddr addr,
383
uint64_t value, unsigned size)
384
{
385
- struct omap_rtc_s *s = (struct omap_rtc_s *) opaque;
386
+ struct omap_rtc_s *s = opaque;
387
int offset = addr & OMAP_MPUI_REG_MASK;
388
struct tm new_tm;
389
time_t ti[2];
390
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_rx_newdata(struct omap_mcbsp_s *s)
391
392
static void omap_mcbsp_source_tick(void *opaque)
393
{
394
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
395
+ struct omap_mcbsp_s *s = opaque;
396
static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 };
397
398
if (!s->rx_rate)
399
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_tx_newdata(struct omap_mcbsp_s *s)
400
401
static void omap_mcbsp_sink_tick(void *opaque)
402
{
403
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
404
+ struct omap_mcbsp_s *s = opaque;
405
static const int bps[8] = { 0, 1, 1, 2, 2, 2, -255, -255 };
406
407
if (!s->tx_rate)
408
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_req_update(struct omap_mcbsp_s *s)
409
static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr,
410
unsigned size)
411
{
412
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
413
+ struct omap_mcbsp_s *s = opaque;
414
int offset = addr & OMAP_MPUI_REG_MASK;
415
uint16_t ret;
416
417
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mcbsp_read(void *opaque, hwaddr addr,
418
static void omap_mcbsp_writeh(void *opaque, hwaddr addr,
419
uint32_t value)
420
{
421
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
422
+ struct omap_mcbsp_s *s = opaque;
423
int offset = addr & OMAP_MPUI_REG_MASK;
424
425
switch (offset) {
426
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_writeh(void *opaque, hwaddr addr,
427
static void omap_mcbsp_writew(void *opaque, hwaddr addr,
428
uint32_t value)
429
{
430
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
431
+ struct omap_mcbsp_s *s = opaque;
432
int offset = addr & OMAP_MPUI_REG_MASK;
433
434
if (offset == 0x04) {                /* DXR */
435
@@ -XXX,XX +XXX,XX @@ static struct omap_mcbsp_s *omap_mcbsp_init(MemoryRegion *system_memory,
436
437
static void omap_mcbsp_i2s_swallow(void *opaque, int line, int level)
438
{
439
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
440
+ struct omap_mcbsp_s *s = opaque;
441
442
if (s->rx_rate) {
443
s->rx_req = s->codec->in.len;
444
@@ -XXX,XX +XXX,XX @@ static void omap_mcbsp_i2s_swallow(void *opaque, int line, int level)
445
446
static void omap_mcbsp_i2s_start(void *opaque, int line, int level)
447
{
448
- struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) opaque;
449
+ struct omap_mcbsp_s *s = opaque;
450
451
if (s->tx_rate) {
452
s->tx_req = s->codec->out.size;
453
@@ -XXX,XX +XXX,XX @@ static void omap_lpg_reset(struct omap_lpg_s *s)
454
omap_lpg_update(s);
455
}
456
457
-static uint64_t omap_lpg_read(void *opaque, hwaddr addr,
458
- unsigned size)
459
+static uint64_t omap_lpg_read(void *opaque, hwaddr addr, unsigned size)
460
{
461
- struct omap_lpg_s *s = (struct omap_lpg_s *) opaque;
462
+ struct omap_lpg_s *s = opaque;
463
int offset = addr & OMAP_MPUI_REG_MASK;
464
465
if (size != 1) {
466
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_lpg_read(void *opaque, hwaddr addr,
467
static void omap_lpg_write(void *opaque, hwaddr addr,
468
uint64_t value, unsigned size)
469
{
470
- struct omap_lpg_s *s = (struct omap_lpg_s *) opaque;
471
+ struct omap_lpg_s *s = opaque;
472
int offset = addr & OMAP_MPUI_REG_MASK;
473
474
if (size != 1) {
475
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_lpg_ops = {
476
477
static void omap_lpg_clk_update(void *opaque, int line, int on)
478
{
479
- struct omap_lpg_s *s = (struct omap_lpg_s *) opaque;
480
+ struct omap_lpg_s *s = opaque;
481
482
s->clk = on;
483
omap_lpg_update(s);
484
@@ -XXX,XX +XXX,XX @@ static void omap_setup_mpui_io(MemoryRegion *system_memory,
485
/* General chip reset */
486
static void omap1_mpu_reset(void *opaque)
487
{
488
- struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
489
+ struct omap_mpu_state_s *mpu = opaque;
490
491
omap_dma_reset(mpu->dma);
492
omap_mpu_timer_reset(mpu->timer[0]);
493
@@ -XXX,XX +XXX,XX @@ static void omap_setup_dsp_mapping(MemoryRegion *system_memory,
494
495
void omap_mpu_wakeup(void *opaque, int irq, int req)
496
{
497
- struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
498
+ struct omap_mpu_state_s *mpu = opaque;
499
CPUState *cpu = CPU(mpu->cpu);
500
501
if (cpu->halted) {
502
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
503
index XXXXXXX..XXXXXXX 100644
504
--- a/hw/arm/omap2.c
505
+++ b/hw/arm/omap2.c
506
@@ -XXX,XX +XXX,XX @@ static inline void omap_eac_out_empty(struct omap_eac_s *s)
507
508
static void omap_eac_in_cb(void *opaque, int avail_b)
509
{
510
- struct omap_eac_s *s = (struct omap_eac_s *) opaque;
511
+ struct omap_eac_s *s = opaque;
512
513
s->codec.rxavail = avail_b >> 2;
514
omap_eac_in_refill(s);
515
@@ -XXX,XX +XXX,XX @@ static void omap_eac_in_cb(void *opaque, int avail_b)
516
517
static void omap_eac_out_cb(void *opaque, int free_b)
518
{
519
- struct omap_eac_s *s = (struct omap_eac_s *) opaque;
520
+ struct omap_eac_s *s = opaque;
521
522
s->codec.txavail = free_b >> 2;
523
if (s->codec.txlen)
524
@@ -XXX,XX +XXX,XX @@ static void omap_eac_reset(struct omap_eac_s *s)
525
omap_eac_interrupt_update(s);
526
}
527
528
-static uint64_t omap_eac_read(void *opaque, hwaddr addr,
529
- unsigned size)
530
+static uint64_t omap_eac_read(void *opaque, hwaddr addr, unsigned size)
531
{
532
- struct omap_eac_s *s = (struct omap_eac_s *) opaque;
533
+ struct omap_eac_s *s = opaque;
534
uint32_t ret;
535
536
if (size != 2) {
537
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_eac_read(void *opaque, hwaddr addr,
538
static void omap_eac_write(void *opaque, hwaddr addr,
539
uint64_t value, unsigned size)
540
{
541
- struct omap_eac_s *s = (struct omap_eac_s *) opaque;
542
+ struct omap_eac_s *s = opaque;
543
544
if (size != 2) {
545
omap_badwidth_write16(opaque, addr, value);
546
@@ -XXX,XX +XXX,XX @@ static void omap_sti_reset(struct omap_sti_s *s)
547
static uint64_t omap_sti_read(void *opaque, hwaddr addr,
548
unsigned size)
549
{
550
- struct omap_sti_s *s = (struct omap_sti_s *) opaque;
551
+ struct omap_sti_s *s = opaque;
552
553
if (size != 4) {
554
return omap_badwidth_read32(opaque, addr);
555
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_sti_read(void *opaque, hwaddr addr,
556
static void omap_sti_write(void *opaque, hwaddr addr,
557
uint64_t value, unsigned size)
558
{
559
- struct omap_sti_s *s = (struct omap_sti_s *) opaque;
560
+ struct omap_sti_s *s = opaque;
561
562
if (size != 4) {
563
omap_badwidth_write32(opaque, addr, value);
564
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_sti_ops = {
565
.endianness = DEVICE_NATIVE_ENDIAN,
566
};
567
568
-static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr,
569
- unsigned size)
570
+static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr, unsigned size)
571
{
572
OMAP_BAD_REG(addr);
573
return 0;
574
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_sti_fifo_read(void *opaque, hwaddr addr,
575
static void omap_sti_fifo_write(void *opaque, hwaddr addr,
576
uint64_t value, unsigned size)
577
{
578
- struct omap_sti_s *s = (struct omap_sti_s *) opaque;
579
+ struct omap_sti_s *s = opaque;
580
int ch = addr >> 6;
581
uint8_t byte = value;
582
583
@@ -XXX,XX +XXX,XX @@ static void omap_prcm_int_update(struct omap_prcm_s *s, int dom)
584
static uint64_t omap_prcm_read(void *opaque, hwaddr addr,
585
unsigned size)
586
{
587
- struct omap_prcm_s *s = (struct omap_prcm_s *) opaque;
588
+ struct omap_prcm_s *s = opaque;
589
uint32_t ret;
590
591
if (size != 4) {
592
@@ -XXX,XX +XXX,XX @@ static void omap_prcm_dpll_update(struct omap_prcm_s *s)
593
static void omap_prcm_write(void *opaque, hwaddr addr,
594
uint64_t value, unsigned size)
595
{
596
- struct omap_prcm_s *s = (struct omap_prcm_s *) opaque;
597
+ struct omap_prcm_s *s = opaque;
598
599
if (size != 4) {
600
omap_badwidth_write32(opaque, addr, value);
601
@@ -XXX,XX +XXX,XX @@ struct omap_sysctl_s {
602
static uint32_t omap_sysctl_read8(void *opaque, hwaddr addr)
603
{
604
605
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
606
+ struct omap_sysctl_s *s = opaque;
607
int pad_offset, byte_offset;
608
int value;
609
610
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_sysctl_read8(void *opaque, hwaddr addr)
611
612
static uint32_t omap_sysctl_read(void *opaque, hwaddr addr)
613
{
614
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
615
+ struct omap_sysctl_s *s = opaque;
616
617
switch (addr) {
618
case 0x000:    /* CONTROL_REVISION */
619
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_sysctl_read(void *opaque, hwaddr addr)
620
return 0;
621
}
622
623
-static void omap_sysctl_write8(void *opaque, hwaddr addr,
624
- uint32_t value)
625
+static void omap_sysctl_write8(void *opaque, hwaddr addr, uint32_t value)
626
{
627
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
628
+ struct omap_sysctl_s *s = opaque;
629
int pad_offset, byte_offset;
630
int prev_value;
631
632
@@ -XXX,XX +XXX,XX @@ static void omap_sysctl_write8(void *opaque, hwaddr addr,
104
}
633
}
105
634
}
106
i = bank_number(old_mode);
635
107
@@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
636
-static void omap_sysctl_write(void *opaque, hwaddr addr,
108
RESULT(sum, n, 16); \
637
- uint32_t value)
109
if (sum >= 0) \
638
+static void omap_sysctl_write(void *opaque, hwaddr addr, uint32_t value)
110
ge |= 3 << (n * 2); \
639
{
111
- } while(0)
640
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
112
+ } while (0)
641
+ struct omap_sysctl_s *s = opaque;
113
642
114
#define SARITH8(a, b, n, op) do { \
643
switch (addr) {
115
int32_t sum; \
644
case 0x000:    /* CONTROL_REVISION */
116
@@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
645
@@ -XXX,XX +XXX,XX @@ static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
117
RESULT(sum, n, 8); \
646
/* General chip reset */
118
if (sum >= 0) \
647
static void omap2_mpu_reset(void *opaque)
119
ge |= 1 << n; \
648
{
120
- } while(0)
649
- struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
121
+ } while (0)
650
+ struct omap_mpu_state_s *mpu = opaque;
122
651
123
652
omap_dma_reset(mpu->dma);
124
#define ADD16(a, b, n) SARITH16(a, b, n, +)
653
omap_prcm_reset(mpu->prcm);
125
@@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
654
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
126
RESULT(sum, n, 16); \
655
index XXXXXXX..XXXXXXX 100644
127
if ((sum >> 16) == 1) \
656
--- a/hw/arm/omap_sx1.c
128
ge |= 3 << (n * 2); \
657
+++ b/hw/arm/omap_sx1.c
129
- } while(0)
658
@@ -XXX,XX +XXX,XX @@
130
+ } while (0)
659
static uint64_t static_read(void *opaque, hwaddr offset,
131
660
unsigned size)
132
#define ADD8(a, b, n) do { \
661
{
133
uint32_t sum; \
662
- uint32_t *val = (uint32_t *) opaque;
134
@@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
663
+ uint32_t *val = opaque;
135
RESULT(sum, n, 8); \
664
uint32_t mask = (4 / size) - 1;
136
if ((sum >> 8) == 1) \
665
137
ge |= 1 << n; \
666
return *val >> ((offset & mask) << 3);
138
- } while(0)
667
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
139
+ } while (0)
668
index XXXXXXX..XXXXXXX 100644
140
669
--- a/hw/arm/palm.c
141
#define SUB16(a, b, n) do { \
670
+++ b/hw/arm/palm.c
142
uint32_t sum; \
671
@@ -XXX,XX +XXX,XX @@ static struct {
143
@@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
672
144
RESULT(sum, n, 16); \
673
static void palmte_button_event(void *opaque, int keycode)
145
if ((sum >> 16) == 0) \
674
{
146
ge |= 3 << (n * 2); \
675
- struct omap_mpu_state_s *cpu = (struct omap_mpu_state_s *) opaque;
147
- } while(0)
676
+ struct omap_mpu_state_s *cpu = opaque;
148
+ } while (0)
677
149
678
if (palmte_keymap[keycode & 0x7f].row != -1)
150
#define SUB8(a, b, n) do { \
679
omap_mpuio_key(cpu->mpuio,
151
uint32_t sum; \
680
diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c
152
@@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
681
index XXXXXXX..XXXXXXX 100644
153
RESULT(sum, n, 8); \
682
--- a/hw/char/omap_uart.c
154
if ((sum >> 8) == 0) \
683
+++ b/hw/char/omap_uart.c
155
ge |= 1 << n; \
684
@@ -XXX,XX +XXX,XX @@ struct omap_uart_s *omap_uart_init(hwaddr base,
156
- } while(0)
685
return s;
157
+ } while (0)
686
}
158
687
159
#define PFX u
688
-static uint64_t omap_uart_read(void *opaque, hwaddr addr,
160
#define ARITH_GE
689
- unsigned size)
690
+static uint64_t omap_uart_read(void *opaque, hwaddr addr, unsigned size)
691
{
692
- struct omap_uart_s *s = (struct omap_uart_s *) opaque;
693
+ struct omap_uart_s *s = opaque;
694
695
if (size == 4) {
696
return omap_badwidth_read8(opaque, addr);
697
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_uart_read(void *opaque, hwaddr addr,
698
static void omap_uart_write(void *opaque, hwaddr addr,
699
uint64_t value, unsigned size)
700
{
701
- struct omap_uart_s *s = (struct omap_uart_s *) opaque;
702
+ struct omap_uart_s *s = opaque;
703
704
if (size == 4) {
705
omap_badwidth_write8(opaque, addr, value);
706
diff --git a/hw/display/omap_dss.c b/hw/display/omap_dss.c
707
index XXXXXXX..XXXXXXX 100644
708
--- a/hw/display/omap_dss.c
709
+++ b/hw/display/omap_dss.c
710
@@ -XXX,XX +XXX,XX @@ void omap_dss_reset(struct omap_dss_s *s)
711
static uint64_t omap_diss_read(void *opaque, hwaddr addr,
712
unsigned size)
713
{
714
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
715
+ struct omap_dss_s *s = opaque;
716
717
if (size != 4) {
718
return omap_badwidth_read32(opaque, addr);
719
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_diss_read(void *opaque, hwaddr addr,
720
static void omap_diss_write(void *opaque, hwaddr addr,
721
uint64_t value, unsigned size)
722
{
723
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
724
+ struct omap_dss_s *s = opaque;
725
726
if (size != 4) {
727
omap_badwidth_write32(opaque, addr, value);
728
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_diss_ops = {
729
static uint64_t omap_disc_read(void *opaque, hwaddr addr,
730
unsigned size)
731
{
732
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
733
+ struct omap_dss_s *s = opaque;
734
735
if (size != 4) {
736
return omap_badwidth_read32(opaque, addr);
737
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_disc_read(void *opaque, hwaddr addr,
738
static void omap_disc_write(void *opaque, hwaddr addr,
739
uint64_t value, unsigned size)
740
{
741
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
742
+ struct omap_dss_s *s = opaque;
743
744
if (size != 4) {
745
omap_badwidth_write32(opaque, addr, value);
746
@@ -XXX,XX +XXX,XX @@ static void omap_rfbi_transfer_start(struct omap_dss_s *s)
747
omap_dispc_interrupt_update(s);
748
}
749
750
-static uint64_t omap_rfbi_read(void *opaque, hwaddr addr,
751
- unsigned size)
752
+static uint64_t omap_rfbi_read(void *opaque, hwaddr addr, unsigned size)
753
{
754
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
755
+ struct omap_dss_s *s = opaque;
756
757
if (size != 4) {
758
return omap_badwidth_read32(opaque, addr);
759
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_rfbi_read(void *opaque, hwaddr addr,
760
static void omap_rfbi_write(void *opaque, hwaddr addr,
761
uint64_t value, unsigned size)
762
{
763
- struct omap_dss_s *s = (struct omap_dss_s *) opaque;
764
+ struct omap_dss_s *s = opaque;
765
766
if (size != 4) {
767
omap_badwidth_write32(opaque, addr, value);
768
diff --git a/hw/display/omap_lcdc.c b/hw/display/omap_lcdc.c
769
index XXXXXXX..XXXXXXX 100644
770
--- a/hw/display/omap_lcdc.c
771
+++ b/hw/display/omap_lcdc.c
772
@@ -XXX,XX +XXX,XX @@ static void draw_line16_32(void *opaque, uint8_t *d, const uint8_t *s,
773
774
static void omap_update_display(void *opaque)
775
{
776
- struct omap_lcd_panel_s *omap_lcd = (struct omap_lcd_panel_s *) opaque;
777
+ struct omap_lcd_panel_s *omap_lcd = opaque;
778
DisplaySurface *surface;
779
drawfn draw_line;
780
int size, height, first, last;
781
@@ -XXX,XX +XXX,XX @@ static void omap_lcd_update(struct omap_lcd_panel_s *s) {
782
}
783
}
784
785
-static uint64_t omap_lcdc_read(void *opaque, hwaddr addr,
786
- unsigned size)
787
+static uint64_t omap_lcdc_read(void *opaque, hwaddr addr, unsigned size)
788
{
789
- struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque;
790
+ struct omap_lcd_panel_s *s = opaque;
791
792
switch (addr) {
793
case 0x00:    /* LCD_CONTROL */
794
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_lcdc_read(void *opaque, hwaddr addr,
795
static void omap_lcdc_write(void *opaque, hwaddr addr,
796
uint64_t value, unsigned size)
797
{
798
- struct omap_lcd_panel_s *s = (struct omap_lcd_panel_s *) opaque;
799
+ struct omap_lcd_panel_s *s = opaque;
800
801
switch (addr) {
802
case 0x00:    /* LCD_CONTROL */
803
diff --git a/hw/dma/omap_dma.c b/hw/dma/omap_dma.c
804
index XXXXXXX..XXXXXXX 100644
805
--- a/hw/dma/omap_dma.c
806
+++ b/hw/dma/omap_dma.c
807
@@ -XXX,XX +XXX,XX @@ static int omap_dma_sys_read(struct omap_dma_s *s, int offset,
808
return 0;
809
}
810
811
-static uint64_t omap_dma_read(void *opaque, hwaddr addr,
812
- unsigned size)
813
+static uint64_t omap_dma_read(void *opaque, hwaddr addr, unsigned size)
814
{
815
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
816
+ struct omap_dma_s *s = opaque;
817
int reg, ch;
818
uint16_t ret;
819
820
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_dma_read(void *opaque, hwaddr addr,
821
static void omap_dma_write(void *opaque, hwaddr addr,
822
uint64_t value, unsigned size)
823
{
824
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
825
+ struct omap_dma_s *s = opaque;
826
int reg, ch;
827
828
if (size != 2) {
829
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_dma_ops = {
830
831
static void omap_dma_request(void *opaque, int drq, int req)
832
{
833
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
834
+ struct omap_dma_s *s = opaque;
835
/* The request pins are level triggered in QEMU. */
836
if (req) {
837
if (~s->dma->drqbmp & (1ULL << drq)) {
838
@@ -XXX,XX +XXX,XX @@ static void omap_dma_request(void *opaque, int drq, int req)
839
/* XXX: this won't be needed once soc_dma knows about clocks. */
840
static void omap_dma_clk_update(void *opaque, int line, int on)
841
{
842
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
843
+ struct omap_dma_s *s = opaque;
844
int i;
845
846
s->dma->freq = omap_clk_getrate(s->clk);
847
@@ -XXX,XX +XXX,XX @@ static void omap_dma_interrupts_4_update(struct omap_dma_s *s)
848
static uint64_t omap_dma4_read(void *opaque, hwaddr addr,
849
unsigned size)
850
{
851
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
852
+ struct omap_dma_s *s = opaque;
853
int irqn = 0, chnum;
854
struct omap_dma_channel_s *ch;
855
856
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_dma4_read(void *opaque, hwaddr addr,
857
static void omap_dma4_write(void *opaque, hwaddr addr,
858
uint64_t value, unsigned size)
859
{
860
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
861
+ struct omap_dma_s *s = opaque;
862
int chnum, irqn = 0;
863
struct omap_dma_channel_s *ch;
864
865
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
866
index XXXXXXX..XXXXXXX 100644
867
--- a/hw/gpio/omap_gpio.c
868
+++ b/hw/gpio/omap_gpio.c
869
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_set(void *opaque, int line, int level)
870
static uint64_t omap_gpio_read(void *opaque, hwaddr addr,
871
unsigned size)
872
{
873
- struct omap_gpio_s *s = (struct omap_gpio_s *) opaque;
874
+ struct omap_gpio_s *s = opaque;
875
int offset = addr & OMAP_MPUI_REG_MASK;
876
877
if (size != 2) {
878
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpio_read(void *opaque, hwaddr addr,
879
static void omap_gpio_write(void *opaque, hwaddr addr,
880
uint64_t value, unsigned size)
881
{
882
- struct omap_gpio_s *s = (struct omap_gpio_s *) opaque;
883
+ struct omap_gpio_s *s = opaque;
884
int offset = addr & OMAP_MPUI_REG_MASK;
885
uint16_t diff;
886
int ln;
887
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_module_reset(struct omap2_gpio_s *s)
888
889
static uint32_t omap2_gpio_module_read(void *opaque, hwaddr addr)
890
{
891
- struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
892
+ struct omap2_gpio_s *s = opaque;
893
894
switch (addr) {
895
case 0x00:    /* GPIO_REVISION */
896
@@ -XXX,XX +XXX,XX @@ static uint32_t omap2_gpio_module_read(void *opaque, hwaddr addr)
897
static void omap2_gpio_module_write(void *opaque, hwaddr addr,
898
uint32_t value)
899
{
900
- struct omap2_gpio_s *s = (struct omap2_gpio_s *) opaque;
901
+ struct omap2_gpio_s *s = opaque;
902
uint32_t diff;
903
int ln;
904
905
@@ -XXX,XX +XXX,XX @@ static void omap2_gpif_reset(DeviceState *dev)
906
s->gpo = 0;
907
}
908
909
-static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr,
910
- unsigned size)
911
+static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size)
912
{
913
- struct omap2_gpif_s *s = (struct omap2_gpif_s *) opaque;
914
+ struct omap2_gpif_s *s = opaque;
915
916
switch (addr) {
917
case 0x00:    /* IPGENERICOCPSPL_REVISION */
918
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr,
919
static void omap2_gpif_top_write(void *opaque, hwaddr addr,
920
uint64_t value, unsigned size)
921
{
922
- struct omap2_gpif_s *s = (struct omap2_gpif_s *) opaque;
923
+ struct omap2_gpif_s *s = opaque;
924
925
switch (addr) {
926
case 0x00:    /* IPGENERICOCPSPL_REVISION */
927
diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c
928
index XXXXXXX..XXXXXXX 100644
929
--- a/hw/intc/omap_intc.c
930
+++ b/hw/intc/omap_intc.c
931
@@ -XXX,XX +XXX,XX @@ static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq)
932
933
static void omap_set_intr(void *opaque, int irq, int req)
934
{
935
- struct omap_intr_handler_s *ih = (struct omap_intr_handler_s *) opaque;
936
+ struct omap_intr_handler_s *ih = opaque;
937
uint32_t rise;
938
939
struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
940
@@ -XXX,XX +XXX,XX @@ static void omap_set_intr(void *opaque, int irq, int req)
941
/* Simplified version with no edge detection */
942
static void omap_set_intr_noedge(void *opaque, int irq, int req)
943
{
944
- struct omap_intr_handler_s *ih = (struct omap_intr_handler_s *) opaque;
945
+ struct omap_intr_handler_s *ih = opaque;
946
uint32_t rise;
947
948
struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
949
@@ -XXX,XX +XXX,XX @@ static void omap_set_intr_noedge(void *opaque, int irq, int req)
950
static uint64_t omap_inth_read(void *opaque, hwaddr addr,
951
unsigned size)
952
{
953
- struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
954
+ struct omap_intr_handler_s *s = opaque;
955
int i, offset = addr;
956
int bank_no = offset >> 8;
957
int line_no;
958
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_inth_read(void *opaque, hwaddr addr,
959
static void omap_inth_write(void *opaque, hwaddr addr,
960
uint64_t value, unsigned size)
961
{
962
- struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
963
+ struct omap_intr_handler_s *s = opaque;
964
int i, offset = addr;
965
int bank_no = offset >> 8;
966
struct omap_intr_handler_bank_s *bank = &s->bank[bank_no];
967
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_intc_info = {
968
static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
969
unsigned size)
970
{
971
- struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
972
+ struct omap_intr_handler_s *s = opaque;
973
int offset = addr;
974
int bank_no, line_no;
975
struct omap_intr_handler_bank_s *bank = NULL;
976
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
977
static void omap2_inth_write(void *opaque, hwaddr addr,
978
uint64_t value, unsigned size)
979
{
980
- struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) opaque;
981
+ struct omap_intr_handler_s *s = opaque;
982
int offset = addr;
983
int bank_no, line_no;
984
struct omap_intr_handler_bank_s *bank = NULL;
985
diff --git a/hw/misc/omap_gpmc.c b/hw/misc/omap_gpmc.c
986
index XXXXXXX..XXXXXXX 100644
987
--- a/hw/misc/omap_gpmc.c
988
+++ b/hw/misc/omap_gpmc.c
989
@@ -XXX,XX +XXX,XX @@ static void omap_gpmc_dma_update(struct omap_gpmc_s *s, int value)
990
static uint64_t omap_nand_read(void *opaque, hwaddr addr,
991
unsigned size)
992
{
993
- struct omap_gpmc_cs_file_s *f = (struct omap_gpmc_cs_file_s *)opaque;
994
+ struct omap_gpmc_cs_file_s *f = opaque;
995
uint64_t v;
996
nand_setpins(f->dev, 0, 0, 0, 1, 0);
997
switch (omap_gpmc_devsize(f)) {
998
@@ -XXX,XX +XXX,XX @@ static void omap_nand_setio(DeviceState *dev, uint64_t value,
999
static void omap_nand_write(void *opaque, hwaddr addr,
1000
uint64_t value, unsigned size)
1001
{
1002
- struct omap_gpmc_cs_file_s *f = (struct omap_gpmc_cs_file_s *)opaque;
1003
+ struct omap_gpmc_cs_file_s *f = opaque;
1004
nand_setpins(f->dev, 0, 0, 0, 1, 0);
1005
omap_nand_setio(f->dev, value, omap_gpmc_devsize(f), size);
1006
}
1007
@@ -XXX,XX +XXX,XX @@ static void fill_prefetch_fifo(struct omap_gpmc_s *s)
1008
static uint64_t omap_gpmc_prefetch_read(void *opaque, hwaddr addr,
1009
unsigned size)
1010
{
1011
- struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
1012
+ struct omap_gpmc_s *s = opaque;
1013
uint32_t data;
1014
if (s->prefetch.config1 & 1) {
1015
/* The TRM doesn't define the behaviour if you read from the
1016
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpmc_prefetch_read(void *opaque, hwaddr addr,
1017
static void omap_gpmc_prefetch_write(void *opaque, hwaddr addr,
1018
uint64_t value, unsigned size)
1019
{
1020
- struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
1021
+ struct omap_gpmc_s *s = opaque;
1022
int cs = prefetch_cs(s->prefetch.config1);
1023
if ((s->prefetch.config1 & 1) == 0) {
1024
/* The TRM doesn't define the behaviour of writing to the
1025
@@ -XXX,XX +XXX,XX @@ static int gpmc_wordaccess_only(hwaddr addr)
1026
static uint64_t omap_gpmc_read(void *opaque, hwaddr addr,
1027
unsigned size)
1028
{
1029
- struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
1030
+ struct omap_gpmc_s *s = opaque;
1031
int cs;
1032
struct omap_gpmc_cs_file_s *f;
1033
1034
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_gpmc_read(void *opaque, hwaddr addr,
1035
static void omap_gpmc_write(void *opaque, hwaddr addr,
1036
uint64_t value, unsigned size)
1037
{
1038
- struct omap_gpmc_s *s = (struct omap_gpmc_s *) opaque;
1039
+ struct omap_gpmc_s *s = opaque;
1040
int cs;
1041
struct omap_gpmc_cs_file_s *f;
1042
1043
diff --git a/hw/misc/omap_l4.c b/hw/misc/omap_l4.c
1044
index XXXXXXX..XXXXXXX 100644
1045
--- a/hw/misc/omap_l4.c
1046
+++ b/hw/misc/omap_l4.c
1047
@@ -XXX,XX +XXX,XX @@ hwaddr omap_l4_region_size(struct omap_target_agent_s *ta,
1048
return ta->start[region].size;
1049
}
1050
1051
-static uint64_t omap_l4ta_read(void *opaque, hwaddr addr,
1052
- unsigned size)
1053
+static uint64_t omap_l4ta_read(void *opaque, hwaddr addr, unsigned size)
1054
{
1055
- struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque;
1056
+ struct omap_target_agent_s *s = opaque;
1057
1058
if (size != 2) {
1059
return omap_badwidth_read16(opaque, addr);
1060
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_l4ta_read(void *opaque, hwaddr addr,
1061
static void omap_l4ta_write(void *opaque, hwaddr addr,
1062
uint64_t value, unsigned size)
1063
{
1064
- struct omap_target_agent_s *s = (struct omap_target_agent_s *) opaque;
1065
+ struct omap_target_agent_s *s = opaque;
1066
1067
if (size != 4) {
1068
omap_badwidth_write32(opaque, addr, value);
1069
diff --git a/hw/misc/omap_sdrc.c b/hw/misc/omap_sdrc.c
1070
index XXXXXXX..XXXXXXX 100644
1071
--- a/hw/misc/omap_sdrc.c
1072
+++ b/hw/misc/omap_sdrc.c
1073
@@ -XXX,XX +XXX,XX @@ void omap_sdrc_reset(struct omap_sdrc_s *s)
1074
s->config = 0x10;
1075
}
1076
1077
-static uint64_t omap_sdrc_read(void *opaque, hwaddr addr,
1078
- unsigned size)
1079
+static uint64_t omap_sdrc_read(void *opaque, hwaddr addr, unsigned size)
1080
{
1081
- struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque;
1082
+ struct omap_sdrc_s *s = opaque;
1083
1084
if (size != 4) {
1085
return omap_badwidth_read32(opaque, addr);
1086
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_sdrc_read(void *opaque, hwaddr addr,
1087
static void omap_sdrc_write(void *opaque, hwaddr addr,
1088
uint64_t value, unsigned size)
1089
{
1090
- struct omap_sdrc_s *s = (struct omap_sdrc_s *) opaque;
1091
+ struct omap_sdrc_s *s = opaque;
1092
1093
if (size != 4) {
1094
omap_badwidth_write32(opaque, addr, value);
1095
diff --git a/hw/misc/omap_tap.c b/hw/misc/omap_tap.c
1096
index XXXXXXX..XXXXXXX 100644
1097
--- a/hw/misc/omap_tap.c
1098
+++ b/hw/misc/omap_tap.c
1099
@@ -XXX,XX +XXX,XX @@
1100
#include "hw/arm/omap.h"
1101
1102
/* TEST-Chip-level TAP */
1103
-static uint64_t omap_tap_read(void *opaque, hwaddr addr,
1104
- unsigned size)
1105
+static uint64_t omap_tap_read(void *opaque, hwaddr addr, unsigned size)
1106
{
1107
- struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) opaque;
1108
+ struct omap_mpu_state_s *s = opaque;
1109
1110
if (size != 4) {
1111
return omap_badwidth_read32(opaque, addr);
1112
diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c
1113
index XXXXXXX..XXXXXXX 100644
1114
--- a/hw/sd/omap_mmc.c
1115
+++ b/hw/sd/omap_mmc.c
1116
@@ -XXX,XX +XXX,XX @@ void omap_mmc_reset(struct omap_mmc_s *host)
1117
device_cold_reset(DEVICE(host->card));
1118
}
1119
1120
-static uint64_t omap_mmc_read(void *opaque, hwaddr offset,
1121
- unsigned size)
1122
+static uint64_t omap_mmc_read(void *opaque, hwaddr offset, unsigned size)
1123
{
1124
uint16_t i;
1125
- struct omap_mmc_s *s = (struct omap_mmc_s *) opaque;
1126
+ struct omap_mmc_s *s = opaque;
1127
1128
if (size != 2) {
1129
return omap_badwidth_read16(opaque, offset);
1130
@@ -XXX,XX +XXX,XX @@ static void omap_mmc_write(void *opaque, hwaddr offset,
1131
uint64_t value, unsigned size)
1132
{
1133
int i;
1134
- struct omap_mmc_s *s = (struct omap_mmc_s *) opaque;
1135
+ struct omap_mmc_s *s = opaque;
1136
1137
if (size != 2) {
1138
omap_badwidth_write16(opaque, offset, value);
1139
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_mmc_ops = {
1140
1141
static void omap_mmc_cover_cb(void *opaque, int line, int level)
1142
{
1143
- struct omap_mmc_s *host = (struct omap_mmc_s *) opaque;
1144
+ struct omap_mmc_s *host = opaque;
1145
1146
if (!host->cdet_state && level) {
1147
host->status |= 0x0002;
1148
diff --git a/hw/ssi/omap_spi.c b/hw/ssi/omap_spi.c
1149
index XXXXXXX..XXXXXXX 100644
1150
--- a/hw/ssi/omap_spi.c
1151
+++ b/hw/ssi/omap_spi.c
1152
@@ -XXX,XX +XXX,XX @@ void omap_mcspi_reset(struct omap_mcspi_s *s)
1153
omap_mcspi_interrupt_update(s);
1154
}
1155
1156
-static uint64_t omap_mcspi_read(void *opaque, hwaddr addr,
1157
- unsigned size)
1158
+static uint64_t omap_mcspi_read(void *opaque, hwaddr addr, unsigned size)
1159
{
1160
- struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque;
1161
+ struct omap_mcspi_s *s = opaque;
1162
int ch = 0;
1163
uint32_t ret;
1164
1165
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_mcspi_read(void *opaque, hwaddr addr,
1166
static void omap_mcspi_write(void *opaque, hwaddr addr,
1167
uint64_t value, unsigned size)
1168
{
1169
- struct omap_mcspi_s *s = (struct omap_mcspi_s *) opaque;
1170
+ struct omap_mcspi_s *s = opaque;
1171
int ch = 0;
1172
1173
if (size != 4) {
1174
diff --git a/hw/timer/omap_gptimer.c b/hw/timer/omap_gptimer.c
1175
index XXXXXXX..XXXXXXX 100644
1176
--- a/hw/timer/omap_gptimer.c
1177
+++ b/hw/timer/omap_gptimer.c
1178
@@ -XXX,XX +XXX,XX @@ static inline void omap_gp_timer_trigger(struct omap_gp_timer_s *timer)
1179
1180
static void omap_gp_timer_tick(void *opaque)
1181
{
1182
- struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
1183
+ struct omap_gp_timer_s *timer = opaque;
1184
1185
if (!timer->ar) {
1186
timer->st = 0;
1187
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_tick(void *opaque)
1188
1189
static void omap_gp_timer_match(void *opaque)
1190
{
1191
- struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
1192
+ struct omap_gp_timer_s *timer = opaque;
1193
1194
if (timer->trigger == gpt_trigger_both)
1195
omap_gp_timer_trigger(timer);
1196
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_match(void *opaque)
1197
1198
static void omap_gp_timer_input(void *opaque, int line, int on)
1199
{
1200
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1201
+ struct omap_gp_timer_s *s = opaque;
1202
int trigger;
1203
1204
switch (s->capture) {
1205
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_input(void *opaque, int line, int on)
1206
1207
static void omap_gp_timer_clk_update(void *opaque, int line, int on)
1208
{
1209
- struct omap_gp_timer_s *timer = (struct omap_gp_timer_s *) opaque;
1210
+ struct omap_gp_timer_s *timer = opaque;
1211
1212
omap_gp_timer_sync(timer);
1213
timer->rate = on ? omap_clk_getrate(timer->clk) : 0;
1214
@@ -XXX,XX +XXX,XX @@ void omap_gp_timer_reset(struct omap_gp_timer_s *s)
1215
1216
static uint32_t omap_gp_timer_readw(void *opaque, hwaddr addr)
1217
{
1218
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1219
+ struct omap_gp_timer_s *s = opaque;
1220
1221
switch (addr) {
1222
case 0x00:    /* TIDR */
1223
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_gp_timer_readw(void *opaque, hwaddr addr)
1224
1225
static uint32_t omap_gp_timer_readh(void *opaque, hwaddr addr)
1226
{
1227
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1228
+ struct omap_gp_timer_s *s = opaque;
1229
uint32_t ret;
1230
1231
if (addr & 2)
1232
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_gp_timer_readh(void *opaque, hwaddr addr)
1233
}
1234
}
1235
1236
-static void omap_gp_timer_write(void *opaque, hwaddr addr,
1237
- uint32_t value)
1238
+static void omap_gp_timer_write(void *opaque, hwaddr addr, uint32_t value)
1239
{
1240
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1241
+ struct omap_gp_timer_s *s = opaque;
1242
1243
switch (addr) {
1244
case 0x00:    /* TIDR */
1245
@@ -XXX,XX +XXX,XX @@ static void omap_gp_timer_write(void *opaque, hwaddr addr,
1246
}
1247
}
1248
1249
-static void omap_gp_timer_writeh(void *opaque, hwaddr addr,
1250
- uint32_t value)
1251
+static void omap_gp_timer_writeh(void *opaque, hwaddr addr, uint32_t value)
1252
{
1253
- struct omap_gp_timer_s *s = (struct omap_gp_timer_s *) opaque;
1254
+ struct omap_gp_timer_s *s = opaque;
1255
1256
if (addr & 2)
1257
omap_gp_timer_write(opaque, addr, (value << 16) | s->writeh);
1258
diff --git a/hw/timer/omap_synctimer.c b/hw/timer/omap_synctimer.c
1259
index XXXXXXX..XXXXXXX 100644
1260
--- a/hw/timer/omap_synctimer.c
1261
+++ b/hw/timer/omap_synctimer.c
1262
@@ -XXX,XX +XXX,XX @@ void omap_synctimer_reset(struct omap_synctimer_s *s)
1263
1264
static uint32_t omap_synctimer_readw(void *opaque, hwaddr addr)
1265
{
1266
- struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
1267
+ struct omap_synctimer_s *s = opaque;
1268
1269
switch (addr) {
1270
case 0x00:    /* 32KSYNCNT_REV */
1271
@@ -XXX,XX +XXX,XX @@ static uint32_t omap_synctimer_readw(void *opaque, hwaddr addr)
1272
1273
static uint32_t omap_synctimer_readh(void *opaque, hwaddr addr)
1274
{
1275
- struct omap_synctimer_s *s = (struct omap_synctimer_s *) opaque;
1276
+ struct omap_synctimer_s *s = opaque;
1277
uint32_t ret;
1278
1279
if (addr & 2)
161
--
1280
--
162
2.25.1
1281
2.34.1
1282
1283
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The CNT register is a read-only register. There is no need to
3
Following docs/devel/style.rst guidelines, rename omap_gpif_s ->
4
store it's value, it can be calculated on demand.
4
Omap1GpioState. This also remove a use of 'struct' in the
5
The calculated frequency is needed temporarily only.
5
DECLARE_INSTANCE_CHECKER() macro call.
6
6
7
Note that this is a migration compatibility break for all boards
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
types that use the EPIT peripheral.
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
9
Message-id: 20230109140306.23161-5-philmd@linaro.org
10
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
11
---
14
include/hw/timer/imx_epit.h | 2 -
12
include/hw/arm/omap.h | 6 +++---
15
hw/timer/imx_epit.c | 73 ++++++++++++++-----------------------
13
hw/gpio/omap_gpio.c | 16 ++++++++--------
16
2 files changed, 28 insertions(+), 47 deletions(-)
14
2 files changed, 11 insertions(+), 11 deletions(-)
17
15
18
diff --git a/include/hw/timer/imx_epit.h b/include/hw/timer/imx_epit.h
16
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
19
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
20
--- a/include/hw/timer/imx_epit.h
18
--- a/include/hw/arm/omap.h
21
+++ b/include/hw/timer/imx_epit.h
19
+++ b/include/hw/arm/omap.h
22
@@ -XXX,XX +XXX,XX @@ struct IMXEPITState {
20
@@ -XXX,XX +XXX,XX @@ void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk);
23
uint32_t sr;
21
24
uint32_t lr;
22
/* omap_gpio.c */
25
uint32_t cmp;
23
#define TYPE_OMAP1_GPIO "omap-gpio"
26
- uint32_t cnt;
24
-DECLARE_INSTANCE_CHECKER(struct omap_gpif_s, OMAP1_GPIO,
27
25
+typedef struct Omap1GpioState Omap1GpioState;
28
- uint32_t freq;
26
+DECLARE_INSTANCE_CHECKER(Omap1GpioState, OMAP1_GPIO,
29
qemu_irq irq;
27
TYPE_OMAP1_GPIO)
28
29
#define TYPE_OMAP2_GPIO "omap2-gpio"
30
DECLARE_INSTANCE_CHECKER(struct omap2_gpif_s, OMAP2_GPIO,
31
TYPE_OMAP2_GPIO)
32
33
-typedef struct omap_gpif_s omap_gpif;
34
typedef struct omap2_gpif_s omap2_gpif;
35
36
/* TODO: clock framework (see above) */
37
-void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk);
38
+void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk);
39
40
void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk);
41
void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk);
42
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
43
index XXXXXXX..XXXXXXX 100644
44
--- a/hw/gpio/omap_gpio.c
45
+++ b/hw/gpio/omap_gpio.c
46
@@ -XXX,XX +XXX,XX @@ struct omap_gpio_s {
47
uint16_t pins;
30
};
48
};
31
49
32
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
50
-struct omap_gpif_s {
33
index XXXXXXX..XXXXXXX 100644
51
+struct Omap1GpioState {
34
--- a/hw/timer/imx_epit.c
52
SysBusDevice parent_obj;
35
+++ b/hw/timer/imx_epit.c
53
36
@@ -XXX,XX +XXX,XX @@ static void imx_epit_update_int(IMXEPITState *s)
54
MemoryRegion iomem;
55
@@ -XXX,XX +XXX,XX @@ struct omap_gpif_s {
56
/* General-Purpose I/O of OMAP1 */
57
static void omap_gpio_set(void *opaque, int line, int level)
58
{
59
- struct omap_gpif_s *p = opaque;
60
+ Omap1GpioState *p = opaque;
61
struct omap_gpio_s *s = &p->omap1;
62
uint16_t prev = s->inputs;
63
64
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_gpio_module_ops = {
65
66
static void omap_gpif_reset(DeviceState *dev)
67
{
68
- struct omap_gpif_s *s = OMAP1_GPIO(dev);
69
+ Omap1GpioState *s = OMAP1_GPIO(dev);
70
71
omap_gpio_reset(&s->omap1);
72
}
73
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_gpif_top_ops = {
74
static void omap_gpio_init(Object *obj)
75
{
76
DeviceState *dev = DEVICE(obj);
77
- struct omap_gpif_s *s = OMAP1_GPIO(obj);
78
+ Omap1GpioState *s = OMAP1_GPIO(obj);
79
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
80
81
qdev_init_gpio_in(dev, omap_gpio_set, 16);
82
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_init(Object *obj)
83
84
static void omap_gpio_realize(DeviceState *dev, Error **errp)
85
{
86
- struct omap_gpif_s *s = OMAP1_GPIO(dev);
87
+ Omap1GpioState *s = OMAP1_GPIO(dev);
88
89
if (!s->clk) {
90
error_setg(errp, "omap-gpio: clk not connected");
91
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_realize(DeviceState *dev, Error **errp)
37
}
92
}
38
}
93
}
39
94
40
-/*
95
-void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk)
41
- * Must be called from within a ptimer_transaction_begin/commit block
96
+void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk)
42
- * for both s->timer_cmp and s->timer_reload.
43
- */
44
-static void imx_epit_set_freq(IMXEPITState *s)
45
+static uint32_t imx_epit_get_freq(IMXEPITState *s)
46
{
97
{
47
- uint32_t clksrc;
98
gpio->clk = clk;
48
- uint32_t prescaler;
49
-
50
- clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, CR_CLKSRC_BITS);
51
- prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, CR_PRESCALE_BITS);
52
-
53
- s->freq = imx_ccm_get_clock_frequency(s->ccm,
54
- imx_epit_clocks[clksrc]) / prescaler;
55
-
56
- DPRINTF("Setting ptimer frequency to %u\n", s->freq);
57
-
58
- if (s->freq) {
59
- ptimer_set_freq(s->timer_reload, s->freq);
60
- ptimer_set_freq(s->timer_cmp, s->freq);
61
- }
62
+ uint32_t clksrc = extract32(s->cr, CR_CLKSRC_SHIFT, CR_CLKSRC_BITS);
63
+ uint32_t prescaler = 1 + extract32(s->cr, CR_PRESCALE_SHIFT, CR_PRESCALE_BITS);
64
+ uint32_t f_in = imx_ccm_get_clock_frequency(s->ccm, imx_epit_clocks[clksrc]);
65
+ uint32_t freq = f_in / prescaler;
66
+ DPRINTF("ptimer frequency is %u\n", freq);
67
+ return freq;
68
}
99
}
69
100
70
/*
101
static Property omap_gpio_properties[] = {
71
@@ -XXX,XX +XXX,XX @@ static void imx_epit_reset(IMXEPITState *s, bool is_hard_reset)
102
- DEFINE_PROP_INT32("mpu_model", struct omap_gpif_s, mpu_model, 0),
72
s->sr = 0;
103
+ DEFINE_PROP_INT32("mpu_model", Omap1GpioState, mpu_model, 0),
73
s->lr = EPIT_TIMER_MAX;
104
DEFINE_PROP_END_OF_LIST(),
74
s->cmp = 0;
105
};
75
- s->cnt = 0;
106
76
ptimer_transaction_begin(s->timer_cmp);
107
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_class_init(ObjectClass *klass, void *data)
77
ptimer_transaction_begin(s->timer_reload);
108
static const TypeInfo omap_gpio_info = {
78
- /* stop both timers */
109
.name = TYPE_OMAP1_GPIO,
79
+
110
.parent = TYPE_SYS_BUS_DEVICE,
80
+ /*
111
- .instance_size = sizeof(struct omap_gpif_s),
81
+ * The reset switches off the input clock, so even if the CR.EN is still
112
+ .instance_size = sizeof(Omap1GpioState),
82
+ * set, the timers are no longer running.
113
.instance_init = omap_gpio_init,
83
+ */
114
.class_init = omap_gpio_class_init,
84
+ assert(imx_epit_get_freq(s) == 0);
115
};
85
ptimer_stop(s->timer_cmp);
86
ptimer_stop(s->timer_reload);
87
- /* compute new frequency */
88
- imx_epit_set_freq(s);
89
/* init both timers to EPIT_TIMER_MAX */
90
ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1);
91
ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1);
92
- if (s->freq && (s->cr & CR_EN)) {
93
- /* if the timer is still enabled, restart it */
94
- ptimer_run(s->timer_reload, 0);
95
- }
96
ptimer_transaction_commit(s->timer_cmp);
97
ptimer_transaction_commit(s->timer_reload);
98
}
99
100
-static uint32_t imx_epit_update_count(IMXEPITState *s)
101
-{
102
- s->cnt = ptimer_get_count(s->timer_reload);
103
-
104
- return s->cnt;
105
-}
106
-
107
static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size)
108
{
109
IMXEPITState *s = IMX_EPIT(opaque);
110
@@ -XXX,XX +XXX,XX @@ static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size)
111
break;
112
113
case 4: /* CNT */
114
- imx_epit_update_count(s);
115
- reg_value = s->cnt;
116
+ reg_value = ptimer_get_count(s->timer_reload);
117
break;
118
119
default:
120
@@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s)
121
{
122
if ((s->cr & (CR_EN | CR_OCIEN)) == (CR_EN | CR_OCIEN)) {
123
/* if the compare feature is on and timers are running */
124
- uint32_t tmp = imx_epit_update_count(s);
125
+ uint32_t tmp = ptimer_get_count(s->timer_reload);
126
uint64_t next;
127
if (tmp > s->cmp) {
128
/* It'll fire in this round of the timer */
129
@@ -XXX,XX +XXX,XX @@ static void imx_epit_reload_compare_timer(IMXEPITState *s)
130
131
static void imx_epit_write_cr(IMXEPITState *s, uint32_t value)
132
{
133
+ uint32_t freq = 0;
134
uint32_t oldcr = s->cr;
135
136
s->cr = value & 0x03ffffff;
137
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write_cr(IMXEPITState *s, uint32_t value)
138
ptimer_transaction_begin(s->timer_cmp);
139
ptimer_transaction_begin(s->timer_reload);
140
141
- /* Update the frequency. Has been done already in case of a reset. */
142
+ /*
143
+ * Update the frequency. In case of a reset the input clock was
144
+ * switched off, so this can be skipped.
145
+ */
146
if (!(s->cr & CR_SWR)) {
147
- imx_epit_set_freq(s);
148
+ freq = imx_epit_get_freq(s);
149
+ if (freq) {
150
+ ptimer_set_freq(s->timer_reload, freq);
151
+ ptimer_set_freq(s->timer_cmp, freq);
152
+ }
153
}
154
155
- if (s->freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {
156
+ if (freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {
157
if (s->cr & CR_ENMOD) {
158
if (s->cr & CR_RLD) {
159
ptimer_set_limit(s->timer_reload, s->lr, 1);
160
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps imx_epit_ops = {
161
162
static const VMStateDescription vmstate_imx_timer_epit = {
163
.name = TYPE_IMX_EPIT,
164
- .version_id = 2,
165
- .minimum_version_id = 2,
166
+ .version_id = 3,
167
+ .minimum_version_id = 3,
168
.fields = (VMStateField[]) {
169
VMSTATE_UINT32(cr, IMXEPITState),
170
VMSTATE_UINT32(sr, IMXEPITState),
171
VMSTATE_UINT32(lr, IMXEPITState),
172
VMSTATE_UINT32(cmp, IMXEPITState),
173
- VMSTATE_UINT32(cnt, IMXEPITState),
174
- VMSTATE_UINT32(freq, IMXEPITState),
175
VMSTATE_PTIMER(timer_reload, IMXEPITState),
176
VMSTATE_PTIMER(timer_cmp, IMXEPITState),
177
VMSTATE_END_OF_LIST()
178
--
116
--
179
2.25.1
117
2.34.1
118
119
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
3
Following docs/devel/style.rst guidelines, rename omap2_gpif_s ->
4
Omap2GpioState. This also remove a use of 'struct' in the
5
DECLARE_INSTANCE_CHECKER() macro call.
2
6
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Message-id: 20221220142520.24094-3-philmd@linaro.org
9
Message-id: 20230109140306.23161-6-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
---
11
---
8
hw/arm/nseries.c | 18 +++++++++---------
12
include/hw/arm/omap.h | 9 ++++-----
9
1 file changed, 9 insertions(+), 9 deletions(-)
13
hw/gpio/omap_gpio.c | 20 ++++++++++----------
14
2 files changed, 14 insertions(+), 15 deletions(-)
10
15
11
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
16
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
12
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/arm/nseries.c
18
--- a/include/hw/arm/omap.h
14
+++ b/hw/arm/nseries.c
19
+++ b/include/hw/arm/omap.h
15
@@ -XXX,XX +XXX,XX @@ static void n8x0_i2c_setup(struct n800_s *s)
20
@@ -XXX,XX +XXX,XX @@ DECLARE_INSTANCE_CHECKER(Omap1GpioState, OMAP1_GPIO,
21
TYPE_OMAP1_GPIO)
22
23
#define TYPE_OMAP2_GPIO "omap2-gpio"
24
-DECLARE_INSTANCE_CHECKER(struct omap2_gpif_s, OMAP2_GPIO,
25
+typedef struct Omap2GpioState Omap2GpioState;
26
+DECLARE_INSTANCE_CHECKER(Omap2GpioState, OMAP2_GPIO,
27
TYPE_OMAP2_GPIO)
28
29
-typedef struct omap2_gpif_s omap2_gpif;
30
-
31
/* TODO: clock framework (see above) */
32
void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk);
33
34
-void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk);
35
-void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk);
36
+void omap2_gpio_set_iclk(Omap2GpioState *gpio, omap_clk clk);
37
+void omap2_gpio_set_fclk(Omap2GpioState *gpio, uint8_t i, omap_clk clk);
38
39
/* OMAP2 l4 Interconnect */
40
struct omap_l4_s;
41
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
42
index XXXXXXX..XXXXXXX 100644
43
--- a/hw/gpio/omap_gpio.c
44
+++ b/hw/gpio/omap_gpio.c
45
@@ -XXX,XX +XXX,XX @@ struct omap2_gpio_s {
46
uint8_t delay;
47
};
48
49
-struct omap2_gpif_s {
50
+struct Omap2GpioState {
51
SysBusDevice parent_obj;
52
53
MemoryRegion iomem;
54
@@ -XXX,XX +XXX,XX @@ static inline void omap2_gpio_module_int(struct omap2_gpio_s *s, int line)
55
56
static void omap2_gpio_set(void *opaque, int line, int level)
57
{
58
- struct omap2_gpif_s *p = opaque;
59
+ Omap2GpioState *p = opaque;
60
struct omap2_gpio_s *s = &p->modules[line >> 5];
61
62
line &= 31;
63
@@ -XXX,XX +XXX,XX @@ static void omap_gpif_reset(DeviceState *dev)
64
65
static void omap2_gpif_reset(DeviceState *dev)
66
{
67
- struct omap2_gpif_s *s = OMAP2_GPIO(dev);
68
+ Omap2GpioState *s = OMAP2_GPIO(dev);
69
int i;
70
71
for (i = 0; i < s->modulecount; i++) {
72
@@ -XXX,XX +XXX,XX @@ static void omap2_gpif_reset(DeviceState *dev)
73
74
static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size)
75
{
76
- struct omap2_gpif_s *s = opaque;
77
+ Omap2GpioState *s = opaque;
78
79
switch (addr) {
80
case 0x00:    /* IPGENERICOCPSPL_REVISION */
81
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_gpif_top_read(void *opaque, hwaddr addr, unsigned size)
82
static void omap2_gpif_top_write(void *opaque, hwaddr addr,
83
uint64_t value, unsigned size)
84
{
85
- struct omap2_gpif_s *s = opaque;
86
+ Omap2GpioState *s = opaque;
87
88
switch (addr) {
89
case 0x00:    /* IPGENERICOCPSPL_REVISION */
90
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_realize(DeviceState *dev, Error **errp)
91
92
static void omap2_gpio_realize(DeviceState *dev, Error **errp)
93
{
94
- struct omap2_gpif_s *s = OMAP2_GPIO(dev);
95
+ Omap2GpioState *s = OMAP2_GPIO(dev);
96
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
97
int i;
98
99
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_gpio_info = {
100
.class_init = omap_gpio_class_init,
101
};
102
103
-void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk)
104
+void omap2_gpio_set_iclk(Omap2GpioState *gpio, omap_clk clk)
105
{
106
gpio->iclk = clk;
16
}
107
}
17
108
18
/* Touchscreen and keypad controller */
109
-void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk)
19
-static MouseTransformInfo n800_pointercal = {
110
+void omap2_gpio_set_fclk(Omap2GpioState *gpio, uint8_t i, omap_clk clk)
20
+static const MouseTransformInfo n800_pointercal = {
111
{
21
.x = 800,
112
assert(i <= 5);
22
.y = 480,
113
gpio->fclk[i] = clk;
23
.a = { 14560, -68, -3455208, -39, -9621, 35152972, 65536 },
114
}
115
116
static Property omap2_gpio_properties[] = {
117
- DEFINE_PROP_INT32("mpu_model", struct omap2_gpif_s, mpu_model, 0),
118
+ DEFINE_PROP_INT32("mpu_model", Omap2GpioState, mpu_model, 0),
119
DEFINE_PROP_END_OF_LIST(),
24
};
120
};
25
121
26
-static MouseTransformInfo n810_pointercal = {
122
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data)
27
+static const MouseTransformInfo n810_pointercal = {
123
static const TypeInfo omap2_gpio_info = {
28
.x = 800,
124
.name = TYPE_OMAP2_GPIO,
29
.y = 480,
125
.parent = TYPE_SYS_BUS_DEVICE,
30
.a = { 15041, 148, -4731056, 171, -10238, 35933380, 65536 },
126
- .instance_size = sizeof(struct omap2_gpif_s),
31
@@ -XXX,XX +XXX,XX @@ static void n810_key_event(void *opaque, int keycode)
127
+ .instance_size = sizeof(Omap2GpioState),
32
128
.class_init = omap2_gpio_class_init,
33
#define M    0
34
35
-static int n810_keys[0x80] = {
36
+static const int n810_keys[0x80] = {
37
[0x01] = 16,    /* Q */
38
[0x02] = 37,    /* K */
39
[0x03] = 24,    /* O */
40
@@ -XXX,XX +XXX,XX @@ static void n8x0_usb_setup(struct n800_s *s)
41
/* Setup done before the main bootloader starts by some early setup code
42
* - used when we want to run the main bootloader in emulation. This
43
* isn't documented. */
44
-static uint32_t n800_pinout[104] = {
45
+static const uint32_t n800_pinout[104] = {
46
0x080f00d8, 0x00d40808, 0x03080808, 0x080800d0,
47
0x00dc0808, 0x0b0f0f00, 0x080800b4, 0x00c00808,
48
0x08080808, 0x180800c4, 0x00b80000, 0x08080808,
49
@@ -XXX,XX +XXX,XX @@ static void n8x0_boot_init(void *opaque)
50
#define OMAP_TAG_CBUS        0x4e03
51
#define OMAP_TAG_EM_ASIC_BB5    0x4e04
52
53
-static struct omap_gpiosw_info_s {
54
+static const struct omap_gpiosw_info_s {
55
const char *name;
56
int line;
57
int type;
58
@@ -XXX,XX +XXX,XX @@ static struct omap_gpiosw_info_s {
59
{ NULL }
60
};
129
};
61
130
62
-static struct omap_partition_info_s {
63
+static const struct omap_partition_info_s {
64
uint32_t offset;
65
uint32_t size;
66
int mask;
67
@@ -XXX,XX +XXX,XX @@ static struct omap_partition_info_s {
68
{ 0, 0, 0, NULL }
69
};
70
71
-static uint8_t n8x0_bd_addr[6] = { N8X0_BD_ADDR };
72
+static const uint8_t n8x0_bd_addr[6] = { N8X0_BD_ADDR };
73
74
static int n8x0_atag_setup(void *p, int model)
75
{
76
uint8_t *b;
77
uint16_t *w;
78
uint32_t *l;
79
- struct omap_gpiosw_info_s *gpiosw;
80
- struct omap_partition_info_s *partition;
81
+ const struct omap_gpiosw_info_s *gpiosw;
82
+ const struct omap_partition_info_s *partition;
83
const char *tag;
84
85
w = p;
86
--
131
--
87
2.25.1
132
2.34.1
88
133
89
134
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Fix typos, add background information
3
Following docs/devel/style.rst guidelines, rename
4
4
omap_intr_handler_s -> OMAPIntcState. This also remove a
5
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
5
use of 'struct' in the DECLARE_INSTANCE_CHECKER() macro call.
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
6
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109140306.23161-7-philmd@linaro.org
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
---
11
---
9
hw/timer/imx_epit.c | 20 ++++++++++++++++----
12
include/hw/arm/omap.h | 9 ++++-----
10
1 file changed, 16 insertions(+), 4 deletions(-)
13
hw/intc/omap_intc.c | 38 +++++++++++++++++++-------------------
11
14
2 files changed, 23 insertions(+), 24 deletions(-)
12
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
15
16
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
13
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
14
--- a/hw/timer/imx_epit.c
18
--- a/include/hw/arm/omap.h
15
+++ b/hw/timer/imx_epit.c
19
+++ b/include/hw/arm/omap.h
16
@@ -XXX,XX +XXX,XX @@ static void imx_epit_set_freq(IMXEPITState *s)
20
@@ -XXX,XX +XXX,XX @@ void omap_clk_reparent(omap_clk clk, omap_clk parent);
21
22
/* omap_intc.c */
23
#define TYPE_OMAP_INTC "common-omap-intc"
24
-typedef struct omap_intr_handler_s omap_intr_handler;
25
-DECLARE_INSTANCE_CHECKER(omap_intr_handler, OMAP_INTC,
26
- TYPE_OMAP_INTC)
27
+typedef struct OMAPIntcState OMAPIntcState;
28
+DECLARE_INSTANCE_CHECKER(OMAPIntcState, OMAP_INTC, TYPE_OMAP_INTC)
29
30
31
/*
32
@@ -XXX,XX +XXX,XX @@ DECLARE_INSTANCE_CHECKER(omap_intr_handler, OMAP_INTC,
33
* (ie the struct omap_mpu_state_s*) to do the clockname to pointer
34
* translation.)
35
*/
36
-void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk);
37
-void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk);
38
+void omap_intc_set_iclk(OMAPIntcState *intc, omap_clk clk);
39
+void omap_intc_set_fclk(OMAPIntcState *intc, omap_clk clk);
40
41
/* omap_i2c.c */
42
#define TYPE_OMAP_I2C "omap_i2c"
43
diff --git a/hw/intc/omap_intc.c b/hw/intc/omap_intc.c
44
index XXXXXXX..XXXXXXX 100644
45
--- a/hw/intc/omap_intc.c
46
+++ b/hw/intc/omap_intc.c
47
@@ -XXX,XX +XXX,XX @@ struct omap_intr_handler_bank_s {
48
unsigned char priority[32];
49
};
50
51
-struct omap_intr_handler_s {
52
+struct OMAPIntcState {
53
SysBusDevice parent_obj;
54
55
qemu_irq *pins;
56
@@ -XXX,XX +XXX,XX @@ struct omap_intr_handler_s {
57
struct omap_intr_handler_bank_s bank[3];
58
};
59
60
-static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq)
61
+static void omap_inth_sir_update(OMAPIntcState *s, int is_fiq)
62
{
63
int i, j, sir_intr, p_intr, p;
64
uint32_t level;
65
@@ -XXX,XX +XXX,XX @@ static void omap_inth_sir_update(struct omap_intr_handler_s *s, int is_fiq)
66
s->sir_intr[is_fiq] = sir_intr;
67
}
68
69
-static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq)
70
+static inline void omap_inth_update(OMAPIntcState *s, int is_fiq)
71
{
72
int i;
73
uint32_t has_intr = 0;
74
@@ -XXX,XX +XXX,XX @@ static inline void omap_inth_update(struct omap_intr_handler_s *s, int is_fiq)
75
76
static void omap_set_intr(void *opaque, int irq, int req)
77
{
78
- struct omap_intr_handler_s *ih = opaque;
79
+ OMAPIntcState *ih = opaque;
80
uint32_t rise;
81
82
struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
83
@@ -XXX,XX +XXX,XX @@ static void omap_set_intr(void *opaque, int irq, int req)
84
/* Simplified version with no edge detection */
85
static void omap_set_intr_noedge(void *opaque, int irq, int req)
86
{
87
- struct omap_intr_handler_s *ih = opaque;
88
+ OMAPIntcState *ih = opaque;
89
uint32_t rise;
90
91
struct omap_intr_handler_bank_s *bank = &ih->bank[irq >> 5];
92
@@ -XXX,XX +XXX,XX @@ static void omap_set_intr_noedge(void *opaque, int irq, int req)
93
static uint64_t omap_inth_read(void *opaque, hwaddr addr,
94
unsigned size)
95
{
96
- struct omap_intr_handler_s *s = opaque;
97
+ OMAPIntcState *s = opaque;
98
int i, offset = addr;
99
int bank_no = offset >> 8;
100
int line_no;
101
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_inth_read(void *opaque, hwaddr addr,
102
static void omap_inth_write(void *opaque, hwaddr addr,
103
uint64_t value, unsigned size)
104
{
105
- struct omap_intr_handler_s *s = opaque;
106
+ OMAPIntcState *s = opaque;
107
int i, offset = addr;
108
int bank_no = offset >> 8;
109
struct omap_intr_handler_bank_s *bank = &s->bank[bank_no];
110
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap_inth_mem_ops = {
111
112
static void omap_inth_reset(DeviceState *dev)
113
{
114
- struct omap_intr_handler_s *s = OMAP_INTC(dev);
115
+ OMAPIntcState *s = OMAP_INTC(dev);
116
int i;
117
118
for (i = 0; i < s->nbanks; ++i){
119
@@ -XXX,XX +XXX,XX @@ static void omap_inth_reset(DeviceState *dev)
120
static void omap_intc_init(Object *obj)
121
{
122
DeviceState *dev = DEVICE(obj);
123
- struct omap_intr_handler_s *s = OMAP_INTC(obj);
124
+ OMAPIntcState *s = OMAP_INTC(obj);
125
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
126
127
s->nbanks = 1;
128
@@ -XXX,XX +XXX,XX @@ static void omap_intc_init(Object *obj)
129
130
static void omap_intc_realize(DeviceState *dev, Error **errp)
131
{
132
- struct omap_intr_handler_s *s = OMAP_INTC(dev);
133
+ OMAPIntcState *s = OMAP_INTC(dev);
134
135
if (!s->iclk) {
136
error_setg(errp, "omap-intc: clk not connected");
17
}
137
}
18
}
138
}
19
139
20
+/*
140
-void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk)
21
+ * This is called both on hardware (device) reset and software reset.
141
+void omap_intc_set_iclk(OMAPIntcState *intc, omap_clk clk)
22
+ */
142
{
23
static void imx_epit_reset(DeviceState *dev)
143
intc->iclk = clk;
24
{
144
}
25
IMXEPITState *s = IMX_EPIT(dev);
145
26
146
-void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk)
27
- /*
147
+void omap_intc_set_fclk(OMAPIntcState *intc, omap_clk clk)
28
- * Soft reset doesn't touch some bits; hard reset clears them
148
{
29
- */
149
intc->fclk = clk;
30
+ /* Soft reset doesn't touch some bits; hard reset clears them */
150
}
31
s->cr &= (CR_EN|CR_ENMOD|CR_STOPEN|CR_DOZEN|CR_WAITEN|CR_DBGEN);
151
32
s->sr = 0;
152
static Property omap_intc_properties[] = {
33
s->lr = EPIT_TIMER_MAX;
153
- DEFINE_PROP_UINT32("size", struct omap_intr_handler_s, size, 0x100),
34
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
154
+ DEFINE_PROP_UINT32("size", OMAPIntcState, size, 0x100),
35
ptimer_transaction_begin(s->timer_cmp);
155
DEFINE_PROP_END_OF_LIST(),
36
ptimer_transaction_begin(s->timer_reload);
156
};
37
157
38
+ /* Update the frequency. Has been done already in case of a reset. */
158
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_intc_info = {
39
if (!(s->cr & CR_SWR)) {
159
static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
40
imx_epit_set_freq(s);
160
unsigned size)
41
}
161
{
42
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write(void *opaque, hwaddr offset, uint64_t value,
162
- struct omap_intr_handler_s *s = opaque;
43
break;
163
+ OMAPIntcState *s = opaque;
44
164
int offset = addr;
45
case 1: /* SR - ACK*/
165
int bank_no, line_no;
46
- /* writing 1 to OCIF clear the OCIF bit */
166
struct omap_intr_handler_bank_s *bank = NULL;
47
+ /* writing 1 to OCIF clears the OCIF bit */
167
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
48
if (value & 0x01) {
168
static void omap2_inth_write(void *opaque, hwaddr addr,
49
s->sr = 0;
169
uint64_t value, unsigned size)
50
imx_epit_update_int(s);
170
{
51
@@ -XXX,XX +XXX,XX @@ static void imx_epit_realize(DeviceState *dev, Error **errp)
171
- struct omap_intr_handler_s *s = opaque;
52
0x00001000);
172
+ OMAPIntcState *s = opaque;
53
sysbus_init_mmio(sbd, &s->iomem);
173
int offset = addr;
54
174
int bank_no, line_no;
55
+ /*
175
struct omap_intr_handler_bank_s *bank = NULL;
56
+ * The reload timer keeps running when the peripheral is enabled. It is a
176
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_inth_mem_ops = {
57
+ * kind of wall clock that does not generate any interrupts. The callback
177
static void omap2_intc_init(Object *obj)
58
+ * needs to be provided, but it does nothing as the ptimer already supports
178
{
59
+ * all necessary reloading functionality.
179
DeviceState *dev = DEVICE(obj);
60
+ */
180
- struct omap_intr_handler_s *s = OMAP_INTC(obj);
61
s->timer_reload = ptimer_init(imx_epit_reload, s, PTIMER_POLICY_LEGACY);
181
+ OMAPIntcState *s = OMAP_INTC(obj);
62
182
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
63
+ /*
183
64
+ * The compare timer is running only when the peripheral configuration is
184
s->level_only = 1;
65
+ * in a state that will generate compare interrupts.
185
@@ -XXX,XX +XXX,XX @@ static void omap2_intc_init(Object *obj)
66
+ */
186
67
s->timer_cmp = ptimer_init(imx_epit_cmp, s, PTIMER_POLICY_LEGACY);
187
static void omap2_intc_realize(DeviceState *dev, Error **errp)
68
}
188
{
189
- struct omap_intr_handler_s *s = OMAP_INTC(dev);
190
+ OMAPIntcState *s = OMAP_INTC(dev);
191
192
if (!s->iclk) {
193
error_setg(errp, "omap2-intc: iclk not connected");
194
@@ -XXX,XX +XXX,XX @@ static void omap2_intc_realize(DeviceState *dev, Error **errp)
195
}
196
197
static Property omap2_intc_properties[] = {
198
- DEFINE_PROP_UINT8("revision", struct omap_intr_handler_s,
199
+ DEFINE_PROP_UINT8("revision", OMAPIntcState,
200
revision, 0x21),
201
DEFINE_PROP_END_OF_LIST(),
202
};
203
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap2_intc_info = {
204
static const TypeInfo omap_intc_type_info = {
205
.name = TYPE_OMAP_INTC,
206
.parent = TYPE_SYS_BUS_DEVICE,
207
- .instance_size = sizeof(omap_intr_handler),
208
+ .instance_size = sizeof(OMAPIntcState),
209
.abstract = true,
210
};
69
211
70
--
212
--
71
2.25.1
213
2.34.1
214
215
diff view generated by jsdifflib
1
From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
ARMv8-R AArch32 CPUs behave as if TTBCR.EAE is always 1 even
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
tough they don't have the TTBCR register.
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
See ARM Architecture Reference Manual Supplement - ARMv8, for the ARMv8-R
5
Message-id: 20230109140306.23161-8-philmd@linaro.org
6
AArch32 architecture profile Version:A.c section C1.2.
7
8
Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
9
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20221206102504.165775-5-tobias.roehmel@rwth-aachen.de
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
7
---
13
target/arm/internals.h | 4 ++++
8
hw/arm/stellaris.c | 6 +++---
14
target/arm/debug_helper.c | 3 +++
9
1 file changed, 3 insertions(+), 3 deletions(-)
15
target/arm/tlb_helper.c | 4 ++++
16
3 files changed, 11 insertions(+)
17
10
18
diff --git a/target/arm/internals.h b/target/arm/internals.h
11
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
19
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
20
--- a/target/arm/internals.h
13
--- a/hw/arm/stellaris.c
21
+++ b/target/arm/internals.h
14
+++ b/hw/arm/stellaris.c
22
@@ -XXX,XX +XXX,XX @@ unsigned int arm_pamax(ARMCPU *cpu);
15
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_update(stellaris_adc_state *s)
23
static inline bool extended_addresses_enabled(CPUARMState *env)
16
17
static void stellaris_adc_trigger(void *opaque, int irq, int level)
24
{
18
{
25
uint64_t tcr = env->cp15.tcr_el[arm_is_secure(env) ? 3 : 1];
19
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
26
+ if (arm_feature(env, ARM_FEATURE_PMSA) &&
20
+ stellaris_adc_state *s = opaque;
27
+ arm_feature(env, ARM_FEATURE_V8)) {
21
int n;
28
+ return true;
22
29
+ }
23
for (n = 0; n < 4; n++) {
30
return arm_el_is_aa64(env, 1) ||
24
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_reset(stellaris_adc_state *s)
31
(arm_feature(env, ARM_FEATURE_LPAE) && (tcr & TTBCR_EAE));
25
static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
32
}
26
unsigned size)
33
diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
27
{
34
index XXXXXXX..XXXXXXX 100644
28
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
35
--- a/target/arm/debug_helper.c
29
+ stellaris_adc_state *s = opaque;
36
+++ b/target/arm/debug_helper.c
30
37
@@ -XXX,XX +XXX,XX @@ static uint32_t arm_debug_exception_fsr(CPUARMState *env)
31
/* TODO: Implement this. */
38
32
if (offset >= 0x40 && offset < 0xc0) {
39
if (target_el == 2 || arm_el_is_aa64(env, target_el)) {
33
@@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
40
using_lpae = true;
34
static void stellaris_adc_write(void *opaque, hwaddr offset,
41
+ } else if (arm_feature(env, ARM_FEATURE_PMSA) &&
35
uint64_t value, unsigned size)
42
+ arm_feature(env, ARM_FEATURE_V8)) {
36
{
43
+ using_lpae = true;
37
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
44
} else {
38
+ stellaris_adc_state *s = opaque;
45
if (arm_feature(env, ARM_FEATURE_LPAE) &&
39
46
(env->cp15.tcr_el[target_el] & TTBCR_EAE)) {
40
/* TODO: Implement this. */
47
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
41
if (offset >= 0x40 && offset < 0xc0) {
48
index XXXXXXX..XXXXXXX 100644
49
--- a/target/arm/tlb_helper.c
50
+++ b/target/arm/tlb_helper.c
51
@@ -XXX,XX +XXX,XX @@ bool regime_using_lpae_format(CPUARMState *env, ARMMMUIdx mmu_idx)
52
if (el == 2 || arm_el_is_aa64(env, el)) {
53
return true;
54
}
55
+ if (arm_feature(env, ARM_FEATURE_PMSA) &&
56
+ arm_feature(env, ARM_FEATURE_V8)) {
57
+ return true;
58
+ }
59
if (arm_feature(env, ARM_FEATURE_LPAE)
60
&& (regime_tcr(env, mmu_idx) & TTBCR_EAE)) {
61
return true;
62
--
42
--
63
2.25.1
43
2.34.1
64
44
65
45
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
When using Clang ("Apple clang version 14.0.0 (clang-1400.0.29.202)")
3
Following docs/devel/style.rst guidelines, rename
4
and building with -Wall we get:
4
stellaris_adc_state -> StellarisADCState. This also remove a
5
use of 'struct' in the DECLARE_INSTANCE_CHECKER() macro call.
5
6
6
hw/arm/smmu-common.c:173:33: warning: static function 'smmu_hash_remove_by_asid_iova' is used in an inline function with external linkage [-Wstatic-in-inline]
7
hw/arm/smmu-common.h:170:1: note: use 'static' to give inline function 'smmu_iotlb_inv_iova' internal linkage
8
void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
9
^
10
static
11
12
None of our code base require / use inlined functions with external
13
linkage. Some places use internal inlining in the hot path. These
14
two functions are certainly not in any hot path and don't justify
15
any inlining, so these are likely oversights rather than intentional.
16
17
Reported-by: Stefan Weil <sw@weilnetz.de>
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
20
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
21
Reviewed-by: Eric Auger <eric.auger@redhat.com>
9
Message-id: 20230109140306.23161-9-philmd@linaro.org
22
Message-id: 20221216214924.4711-3-philmd@linaro.org
23
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
24
---
11
---
25
hw/arm/smmu-common.c | 13 ++++++-------
12
hw/arm/stellaris.c | 73 +++++++++++++++++++++++-----------------------
26
1 file changed, 6 insertions(+), 7 deletions(-)
13
1 file changed, 36 insertions(+), 37 deletions(-)
27
14
28
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
15
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
29
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
30
--- a/hw/arm/smmu-common.c
17
--- a/hw/arm/stellaris.c
31
+++ b/hw/arm/smmu-common.c
18
+++ b/hw/arm/stellaris.c
32
@@ -XXX,XX +XXX,XX @@ void smmu_iotlb_insert(SMMUState *bs, SMMUTransCfg *cfg, SMMUTLBEntry *new)
19
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_init(Object *obj)
33
g_hash_table_insert(bs->iotlb, key, new);
20
#define STELLARIS_ADC_FIFO_FULL 0x1000
21
22
#define TYPE_STELLARIS_ADC "stellaris-adc"
23
-typedef struct StellarisADCState stellaris_adc_state;
24
-DECLARE_INSTANCE_CHECKER(stellaris_adc_state, STELLARIS_ADC,
25
- TYPE_STELLARIS_ADC)
26
+typedef struct StellarisADCState StellarisADCState;
27
+DECLARE_INSTANCE_CHECKER(StellarisADCState, STELLARIS_ADC, TYPE_STELLARIS_ADC)
28
29
struct StellarisADCState {
30
SysBusDevice parent_obj;
31
@@ -XXX,XX +XXX,XX @@ struct StellarisADCState {
32
qemu_irq irq[4];
33
};
34
35
-static uint32_t stellaris_adc_fifo_read(stellaris_adc_state *s, int n)
36
+static uint32_t stellaris_adc_fifo_read(StellarisADCState *s, int n)
37
{
38
int tail;
39
40
@@ -XXX,XX +XXX,XX @@ static uint32_t stellaris_adc_fifo_read(stellaris_adc_state *s, int n)
41
return s->fifo[n].data[tail];
34
}
42
}
35
43
36
-inline void smmu_iotlb_inv_all(SMMUState *s)
44
-static void stellaris_adc_fifo_write(stellaris_adc_state *s, int n,
37
+void smmu_iotlb_inv_all(SMMUState *s)
45
+static void stellaris_adc_fifo_write(StellarisADCState *s, int n,
46
uint32_t value)
38
{
47
{
39
trace_smmu_iotlb_inv_all();
48
int head;
40
g_hash_table_remove_all(s->iotlb);
49
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_fifo_write(stellaris_adc_state *s, int n,
41
@@ -XXX,XX +XXX,XX @@ static gboolean smmu_hash_remove_by_asid_iova(gpointer key, gpointer value,
50
s->fifo[n].state |= STELLARIS_ADC_FIFO_FULL;
42
((entry->iova & ~info->mask) == info->iova);
43
}
51
}
44
52
45
-inline void
53
-static void stellaris_adc_update(stellaris_adc_state *s)
46
-smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
54
+static void stellaris_adc_update(StellarisADCState *s)
47
- uint8_t tg, uint64_t num_pages, uint8_t ttl)
48
+void smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
49
+ uint8_t tg, uint64_t num_pages, uint8_t ttl)
50
{
55
{
51
/* if tg is not set we use 4KB range invalidation */
56
int level;
52
uint8_t granule = tg ? tg * 2 + 10 : 12;
57
int n;
53
@@ -XXX,XX +XXX,XX @@ smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
58
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_update(stellaris_adc_state *s)
54
&info);
59
60
static void stellaris_adc_trigger(void *opaque, int irq, int level)
61
{
62
- stellaris_adc_state *s = opaque;
63
+ StellarisADCState *s = opaque;
64
int n;
65
66
for (n = 0; n < 4; n++) {
67
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_trigger(void *opaque, int irq, int level)
68
}
55
}
69
}
56
70
57
-inline void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid)
71
-static void stellaris_adc_reset(stellaris_adc_state *s)
58
+void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid)
72
+static void stellaris_adc_reset(StellarisADCState *s)
59
{
73
{
60
trace_smmu_iotlb_inv_asid(asid);
74
int n;
61
g_hash_table_foreach_remove(s->iotlb, smmu_hash_remove_by_asid, &asid);
75
62
@@ -XXX,XX +XXX,XX @@ error:
76
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_reset(stellaris_adc_state *s)
63
*
77
static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
64
* return 0 on success
78
unsigned size)
65
*/
66
-inline int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm,
67
- SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info)
68
+int smmu_ptw(SMMUTransCfg *cfg, dma_addr_t iova, IOMMUAccessFlags perm,
69
+ SMMUTLBEntry *tlbe, SMMUPTWEventInfo *info)
70
{
79
{
71
if (!cfg->aa64) {
80
- stellaris_adc_state *s = opaque;
72
/*
81
+ StellarisADCState *s = opaque;
82
83
/* TODO: Implement this. */
84
if (offset >= 0x40 && offset < 0xc0) {
85
@@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
86
static void stellaris_adc_write(void *opaque, hwaddr offset,
87
uint64_t value, unsigned size)
88
{
89
- stellaris_adc_state *s = opaque;
90
+ StellarisADCState *s = opaque;
91
92
/* TODO: Implement this. */
93
if (offset >= 0x40 && offset < 0xc0) {
94
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_adc = {
95
.version_id = 1,
96
.minimum_version_id = 1,
97
.fields = (VMStateField[]) {
98
- VMSTATE_UINT32(actss, stellaris_adc_state),
99
- VMSTATE_UINT32(ris, stellaris_adc_state),
100
- VMSTATE_UINT32(im, stellaris_adc_state),
101
- VMSTATE_UINT32(emux, stellaris_adc_state),
102
- VMSTATE_UINT32(ostat, stellaris_adc_state),
103
- VMSTATE_UINT32(ustat, stellaris_adc_state),
104
- VMSTATE_UINT32(sspri, stellaris_adc_state),
105
- VMSTATE_UINT32(sac, stellaris_adc_state),
106
- VMSTATE_UINT32(fifo[0].state, stellaris_adc_state),
107
- VMSTATE_UINT32_ARRAY(fifo[0].data, stellaris_adc_state, 16),
108
- VMSTATE_UINT32(ssmux[0], stellaris_adc_state),
109
- VMSTATE_UINT32(ssctl[0], stellaris_adc_state),
110
- VMSTATE_UINT32(fifo[1].state, stellaris_adc_state),
111
- VMSTATE_UINT32_ARRAY(fifo[1].data, stellaris_adc_state, 16),
112
- VMSTATE_UINT32(ssmux[1], stellaris_adc_state),
113
- VMSTATE_UINT32(ssctl[1], stellaris_adc_state),
114
- VMSTATE_UINT32(fifo[2].state, stellaris_adc_state),
115
- VMSTATE_UINT32_ARRAY(fifo[2].data, stellaris_adc_state, 16),
116
- VMSTATE_UINT32(ssmux[2], stellaris_adc_state),
117
- VMSTATE_UINT32(ssctl[2], stellaris_adc_state),
118
- VMSTATE_UINT32(fifo[3].state, stellaris_adc_state),
119
- VMSTATE_UINT32_ARRAY(fifo[3].data, stellaris_adc_state, 16),
120
- VMSTATE_UINT32(ssmux[3], stellaris_adc_state),
121
- VMSTATE_UINT32(ssctl[3], stellaris_adc_state),
122
- VMSTATE_UINT32(noise, stellaris_adc_state),
123
+ VMSTATE_UINT32(actss, StellarisADCState),
124
+ VMSTATE_UINT32(ris, StellarisADCState),
125
+ VMSTATE_UINT32(im, StellarisADCState),
126
+ VMSTATE_UINT32(emux, StellarisADCState),
127
+ VMSTATE_UINT32(ostat, StellarisADCState),
128
+ VMSTATE_UINT32(ustat, StellarisADCState),
129
+ VMSTATE_UINT32(sspri, StellarisADCState),
130
+ VMSTATE_UINT32(sac, StellarisADCState),
131
+ VMSTATE_UINT32(fifo[0].state, StellarisADCState),
132
+ VMSTATE_UINT32_ARRAY(fifo[0].data, StellarisADCState, 16),
133
+ VMSTATE_UINT32(ssmux[0], StellarisADCState),
134
+ VMSTATE_UINT32(ssctl[0], StellarisADCState),
135
+ VMSTATE_UINT32(fifo[1].state, StellarisADCState),
136
+ VMSTATE_UINT32_ARRAY(fifo[1].data, StellarisADCState, 16),
137
+ VMSTATE_UINT32(ssmux[1], StellarisADCState),
138
+ VMSTATE_UINT32(ssctl[1], StellarisADCState),
139
+ VMSTATE_UINT32(fifo[2].state, StellarisADCState),
140
+ VMSTATE_UINT32_ARRAY(fifo[2].data, StellarisADCState, 16),
141
+ VMSTATE_UINT32(ssmux[2], StellarisADCState),
142
+ VMSTATE_UINT32(ssctl[2], StellarisADCState),
143
+ VMSTATE_UINT32(fifo[3].state, StellarisADCState),
144
+ VMSTATE_UINT32_ARRAY(fifo[3].data, StellarisADCState, 16),
145
+ VMSTATE_UINT32(ssmux[3], StellarisADCState),
146
+ VMSTATE_UINT32(ssctl[3], StellarisADCState),
147
+ VMSTATE_UINT32(noise, StellarisADCState),
148
VMSTATE_END_OF_LIST()
149
}
150
};
151
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_adc = {
152
static void stellaris_adc_init(Object *obj)
153
{
154
DeviceState *dev = DEVICE(obj);
155
- stellaris_adc_state *s = STELLARIS_ADC(obj);
156
+ StellarisADCState *s = STELLARIS_ADC(obj);
157
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
158
int n;
159
160
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_class_init(ObjectClass *klass, void *data)
161
static const TypeInfo stellaris_adc_info = {
162
.name = TYPE_STELLARIS_ADC,
163
.parent = TYPE_SYS_BUS_DEVICE,
164
- .instance_size = sizeof(stellaris_adc_state),
165
+ .instance_size = sizeof(StellarisADCState),
166
.instance_init = stellaris_adc_init,
167
.class_init = stellaris_adc_class_init,
168
};
73
--
169
--
74
2.25.1
170
2.34.1
75
171
76
172
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The pointed MouseTransformInfo structure is accessed read-only.
3
The typedef and definitions are generated by the OBJECT_DECLARE_TYPE
4
macro in "hw/arm/bcm2836.h":
5
6
20 #define TYPE_BCM283X "bcm283x"
7
21 OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X)
8
9
The script ran in commit a489d1951c ("Use OBJECT_DECLARE_TYPE when
10
possible") missed them because they are declared in a different
11
file unit. Remove them.
4
12
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20221220142520.24094-2-philmd@linaro.org
15
Message-id: 20230109140306.23161-10-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
17
---
10
include/hw/input/tsc2xxx.h | 4 ++--
18
hw/arm/bcm2836.c | 9 ++-------
11
hw/input/tsc2005.c | 2 +-
19
1 file changed, 2 insertions(+), 7 deletions(-)
12
hw/input/tsc210x.c | 3 +--
13
3 files changed, 4 insertions(+), 5 deletions(-)
14
20
15
diff --git a/include/hw/input/tsc2xxx.h b/include/hw/input/tsc2xxx.h
21
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
16
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
17
--- a/include/hw/input/tsc2xxx.h
23
--- a/hw/arm/bcm2836.c
18
+++ b/include/hw/input/tsc2xxx.h
24
+++ b/hw/arm/bcm2836.c
19
@@ -XXX,XX +XXX,XX @@ uWireSlave *tsc2102_init(qemu_irq pint);
25
@@ -XXX,XX +XXX,XX @@
20
uWireSlave *tsc2301_init(qemu_irq penirq, qemu_irq kbirq, qemu_irq dav);
26
#include "hw/arm/raspi_platform.h"
21
I2SCodec *tsc210x_codec(uWireSlave *chip);
27
#include "hw/sysbus.h"
22
uint32_t tsc210x_txrx(void *opaque, uint32_t value, int len);
28
23
-void tsc210x_set_transform(uWireSlave *chip, MouseTransformInfo *info);
29
-typedef struct BCM283XClass {
24
+void tsc210x_set_transform(uWireSlave *chip, const MouseTransformInfo *info);
30
+struct BCM283XClass {
25
void tsc210x_key_event(uWireSlave *chip, int key, int down);
31
/*< private >*/
26
32
DeviceClass parent_class;
27
/* tsc2005.c */
33
/*< public >*/
28
void *tsc2005_init(qemu_irq pintdav);
34
@@ -XXX,XX +XXX,XX @@ typedef struct BCM283XClass {
29
uint32_t tsc2005_txrx(void *opaque, uint32_t value, int len);
35
hwaddr peri_base; /* Peripheral base address seen by the CPU */
30
-void tsc2005_set_transform(void *opaque, MouseTransformInfo *info);
36
hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */
31
+void tsc2005_set_transform(void *opaque, const MouseTransformInfo *info);
37
int clusterid;
32
38
-} BCM283XClass;
33
#endif
39
-
34
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
40
-#define BCM283X_CLASS(klass) \
35
index XXXXXXX..XXXXXXX 100644
41
- OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X)
36
--- a/hw/input/tsc2005.c
42
-#define BCM283X_GET_CLASS(obj) \
37
+++ b/hw/input/tsc2005.c
43
- OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X)
38
@@ -XXX,XX +XXX,XX @@ void *tsc2005_init(qemu_irq pintdav)
44
+};
39
* from the touchscreen. Assuming 12-bit precision was used during
45
40
* tslib calibration.
46
static Property bcm2836_enabled_cores_property =
41
*/
47
DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, 0);
42
-void tsc2005_set_transform(void *opaque, MouseTransformInfo *info)
43
+void tsc2005_set_transform(void *opaque, const MouseTransformInfo *info)
44
{
45
TSC2005State *s = (TSC2005State *) opaque;
46
47
diff --git a/hw/input/tsc210x.c b/hw/input/tsc210x.c
48
index XXXXXXX..XXXXXXX 100644
49
--- a/hw/input/tsc210x.c
50
+++ b/hw/input/tsc210x.c
51
@@ -XXX,XX +XXX,XX @@ I2SCodec *tsc210x_codec(uWireSlave *chip)
52
* from the touchscreen. Assuming 12-bit precision was used during
53
* tslib calibration.
54
*/
55
-void tsc210x_set_transform(uWireSlave *chip,
56
- MouseTransformInfo *info)
57
+void tsc210x_set_transform(uWireSlave *chip, const MouseTransformInfo *info)
58
{
59
TSC210xState *s = (TSC210xState *) chip->opaque;
60
#if 0
61
--
48
--
62
2.25.1
49
2.34.1
63
50
64
51
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Fix these:
3
NPCM7XX models have been commited after the conversion from
4
4
commit 8063396bf3 ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible").
5
WARNING: Block comments use a leading /* on a separate line
5
Manually convert them.
6
WARNING: Block comments use * on subsequent lines
6
7
WARNING: Block comments use a trailing */ on a separate line
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Fabiano Rosas <farosas@suse.de>
9
Message-id: 20230109140306.23161-11-philmd@linaro.org
10
Reviewed-by: Claudio Fontana <cfontana@suse.de>
11
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
12
Message-id: 20221213190537.511-2-farosas@suse.de
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/helper.c | 323 +++++++++++++++++++++++++++++---------------
12
include/hw/adc/npcm7xx_adc.h | 7 +++----
16
1 file changed, 215 insertions(+), 108 deletions(-)
13
include/hw/arm/npcm7xx.h | 18 ++++++------------
17
14
include/hw/i2c/npcm7xx_smbus.h | 7 +++----
18
diff --git a/target/arm/helper.c b/target/arm/helper.c
15
include/hw/misc/npcm7xx_clk.h | 2 +-
19
index XXXXXXX..XXXXXXX 100644
16
include/hw/misc/npcm7xx_gcr.h | 6 +++---
20
--- a/target/arm/helper.c
17
include/hw/misc/npcm7xx_mft.h | 7 +++----
21
+++ b/target/arm/helper.c
18
include/hw/misc/npcm7xx_pwm.h | 3 +--
22
@@ -XXX,XX +XXX,XX @@ uint64_t read_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri)
19
include/hw/misc/npcm7xx_rng.h | 6 +++---
23
static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri,
20
include/hw/net/npcm7xx_emc.h | 5 +----
24
uint64_t v)
21
include/hw/sd/npcm7xx_sdhci.h | 4 ++--
25
{
22
10 files changed, 26 insertions(+), 39 deletions(-)
26
- /* Raw write of a coprocessor register (as needed for migration, etc).
23
27
+ /*
24
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
28
+ * Raw write of a coprocessor register (as needed for migration, etc).
25
index XXXXXXX..XXXXXXX 100644
29
* Note that constant registers are treated as write-ignored; the
26
--- a/include/hw/adc/npcm7xx_adc.h
30
* caller should check for success by whether a readback gives the
27
+++ b/include/hw/adc/npcm7xx_adc.h
31
* value written.
28
@@ -XXX,XX +XXX,XX @@
32
@@ -XXX,XX +XXX,XX @@ static void write_raw_cp_reg(CPUARMState *env, const ARMCPRegInfo *ri,
29
* @iref: The internal reference voltage, initialized at launch time.
33
30
* @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
34
static bool raw_accessors_invalid(const ARMCPRegInfo *ri)
31
*/
35
{
32
-typedef struct {
36
- /* Return true if the regdef would cause an assertion if you called
33
+struct NPCM7xxADCState {
37
+ /*
34
SysBusDevice parent;
38
+ * Return true if the regdef would cause an assertion if you called
35
39
* read_raw_cp_reg() or write_raw_cp_reg() on it (ie if it is a
36
MemoryRegion iomem;
40
* program bug for it not to have the NO_RAW flag).
37
@@ -XXX,XX +XXX,XX @@ typedef struct {
41
* NB that returning false here doesn't necessarily mean that calling
38
uint32_t iref;
42
@@ -XXX,XX +XXX,XX @@ bool write_list_to_cpustate(ARMCPU *cpu)
39
43
if (ri->type & ARM_CP_NO_RAW) {
40
uint16_t calibration_r_values[NPCM7XX_ADC_NUM_CALIB];
44
continue;
41
-} NPCM7xxADCState;
45
}
42
+};
46
- /* Write value and confirm it reads back as written
43
47
+ /*
44
#define TYPE_NPCM7XX_ADC "npcm7xx-adc"
48
+ * Write value and confirm it reads back as written
45
-#define NPCM7XX_ADC(obj) \
49
* (to catch read-only registers and partially read-only
46
- OBJECT_CHECK(NPCM7xxADCState, (obj), TYPE_NPCM7XX_ADC)
50
* registers where the incoming migration value doesn't match)
47
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxADCState, NPCM7XX_ADC)
51
*/
48
52
@@ -XXX,XX +XXX,XX @@ static gint cpreg_key_compare(gconstpointer a, gconstpointer b)
49
#endif /* NPCM7XX_ADC_H */
53
50
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
54
void init_cpreg_list(ARMCPU *cpu)
51
index XXXXXXX..XXXXXXX 100644
55
{
52
--- a/include/hw/arm/npcm7xx.h
56
- /* Initialise the cpreg_tuples[] array based on the cp_regs hash.
53
+++ b/include/hw/arm/npcm7xx.h
57
+ /*
54
@@ -XXX,XX +XXX,XX @@
58
+ * Initialise the cpreg_tuples[] array based on the cp_regs hash.
55
59
* Note that we require cpreg_tuples[] to be sorted by key ID.
56
#define NPCM7XX_NR_PWM_MODULES 2
57
58
-typedef struct NPCM7xxMachine {
59
+struct NPCM7xxMachine {
60
MachineState parent;
61
/*
62
* PWM fan splitter. each splitter connects to one PWM output and
63
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMachine {
60
*/
64
*/
61
GList *keys;
65
SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES *
62
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_el3_aa32ns(CPUARMState *env,
66
NPCM7XX_PWM_PER_MODULE];
63
return CP_ACCESS_OK;
67
-} NPCM7xxMachine;
64
}
68
+};
65
69
66
-/* Some secure-only AArch32 registers trap to EL3 if used from
70
#define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
67
+/*
71
-#define NPCM7XX_MACHINE(obj) \
68
+ * Some secure-only AArch32 registers trap to EL3 if used from
72
- OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE)
69
* Secure EL1 (but are just ordinary UNDEF in other non-EL3 contexts).
73
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMachine, NPCM7XX_MACHINE)
70
* Note that an access from Secure EL1 can only happen if EL3 is AArch64.
74
71
* We assume that the .access field is set to PL1_RW.
75
typedef struct NPCM7xxMachineClass {
72
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_trap_aa32s_el1(CPUARMState *env,
76
MachineClass parent;
73
return CP_ACCESS_TRAP_UNCATEGORIZED;
77
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMachineClass {
74
}
78
#define NPCM7XX_MACHINE_GET_CLASS(obj) \
75
79
OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
76
-/* Check for traps to performance monitor registers, which are controlled
80
77
+/*
81
-typedef struct NPCM7xxState {
78
+ * Check for traps to performance monitor registers, which are controlled
82
+struct NPCM7xxState {
79
* by MDCR_EL2.TPM for EL2 and MDCR_EL3.TPM for EL3.
83
DeviceState parent;
80
*/
84
81
static CPAccessResult access_tpm(CPUARMState *env, const ARMCPRegInfo *ri,
85
ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS];
82
@@ -XXX,XX +XXX,XX @@ static void fcse_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
86
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState {
83
ARMCPU *cpu = env_archcpu(env);
87
NPCM7xxFIUState fiu[2];
84
88
NPCM7xxEMCState emc[2];
85
if (raw_read(env, ri) != value) {
89
NPCM7xxSDHCIState mmc;
86
- /* Unlike real hardware the qemu TLB uses virtual addresses,
90
-} NPCM7xxState;
87
+ /*
91
+};
88
+ * Unlike real hardware the qemu TLB uses virtual addresses,
92
89
* not modified virtual addresses, so this causes a TLB flush.
93
#define TYPE_NPCM7XX "npcm7xx"
90
*/
94
-#define NPCM7XX(obj) OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX)
91
tlb_flush(CPU(cpu));
95
+OBJECT_DECLARE_TYPE(NPCM7xxState, NPCM7xxClass, NPCM7XX)
92
@@ -XXX,XX +XXX,XX @@ static void contextidr_write(CPUARMState *env, const ARMCPRegInfo *ri,
96
93
97
#define TYPE_NPCM730 "npcm730"
94
if (raw_read(env, ri) != value && !arm_feature(env, ARM_FEATURE_PMSA)
98
#define TYPE_NPCM750 "npcm750"
95
&& !extended_addresses_enabled(env)) {
99
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxClass {
96
- /* For VMSA (when not using the LPAE long descriptor page table
100
uint32_t num_cpus;
97
+ /*
101
} NPCM7xxClass;
98
+ * For VMSA (when not using the LPAE long descriptor page table
102
99
* format) this register includes the ASID, so do a TLB flush.
103
-#define NPCM7XX_CLASS(klass) \
100
* For PMSA it is purely a process ID and no action is needed.
104
- OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX)
101
*/
105
-#define NPCM7XX_GET_CLASS(obj) \
102
@@ -XXX,XX +XXX,XX @@ static void tlbiipas2is_hyp_write(CPUARMState *env, const ARMCPRegInfo *ri,
106
- OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX)
103
}
107
-
104
108
/**
105
static const ARMCPRegInfo cp_reginfo[] = {
109
* npcm7xx_load_kernel - Loads memory with everything needed to boot
106
- /* Define the secure and non-secure FCSE identifier CP registers
110
* @machine - The machine containing the SoC to be booted.
107
+ /*
111
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
108
+ * Define the secure and non-secure FCSE identifier CP registers
112
index XXXXXXX..XXXXXXX 100644
109
* separately because there is no secure bank in V8 (no _EL3). This allows
113
--- a/include/hw/i2c/npcm7xx_smbus.h
110
* the secure register to be properly reset and migrated. There is also no
114
+++ b/include/hw/i2c/npcm7xx_smbus.h
111
* v8 EL1 version of the register so the non-secure instance stands alone.
115
@@ -XXX,XX +XXX,XX @@ typedef enum NPCM7xxSMBusStatus {
112
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = {
116
* @rx_cur: The current position of rx_fifo.
113
.access = PL1_RW, .secure = ARM_CP_SECSTATE_S,
117
* @status: The current status of the SMBus.
114
.fieldoffset = offsetof(CPUARMState, cp15.fcseidr_s),
118
*/
115
.resetvalue = 0, .writefn = fcse_write, .raw_writefn = raw_write, },
119
-typedef struct NPCM7xxSMBusState {
116
- /* Define the secure and non-secure context identifier CP registers
120
+struct NPCM7xxSMBusState {
117
+ /*
121
SysBusDevice parent;
118
+ * Define the secure and non-secure context identifier CP registers
122
119
* separately because there is no secure bank in V8 (no _EL3). This allows
123
MemoryRegion iomem;
120
* the secure register to be properly reset and migrated. In the
124
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxSMBusState {
121
* non-secure case, the 32-bit register will have reset and migration
125
uint8_t rx_cur;
122
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cp_reginfo[] = {
126
127
NPCM7xxSMBusStatus status;
128
-} NPCM7xxSMBusState;
129
+};
130
131
#define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus"
132
-#define NPCM7XX_SMBUS(obj) OBJECT_CHECK(NPCM7xxSMBusState, (obj), \
133
- TYPE_NPCM7XX_SMBUS)
134
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxSMBusState, NPCM7XX_SMBUS)
135
136
#endif /* NPCM7XX_SMBUS_H */
137
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
138
index XXXXXXX..XXXXXXX 100644
139
--- a/include/hw/misc/npcm7xx_clk.h
140
+++ b/include/hw/misc/npcm7xx_clk.h
141
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxCLKState {
123
};
142
};
124
143
125
static const ARMCPRegInfo not_v8_cp_reginfo[] = {
144
#define TYPE_NPCM7XX_CLK "npcm7xx-clk"
126
- /* NB: Some of these registers exist in v8 but with more precise
145
-#define NPCM7XX_CLK(obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK)
127
+ /*
146
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxCLKState, NPCM7XX_CLK)
128
+ * NB: Some of these registers exist in v8 but with more precise
147
129
* definitions that don't use CP_ANY wildcards (mostly in v8_cp_reginfo[]).
148
#endif /* NPCM7XX_CLK_H */
130
*/
149
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
131
/* MMU Domain access control / MPU write buffer control */
150
index XXXXXXX..XXXXXXX 100644
132
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = {
151
--- a/include/hw/misc/npcm7xx_gcr.h
133
.writefn = dacr_write, .raw_writefn = raw_write,
152
+++ b/include/hw/misc/npcm7xx_gcr.h
134
.bank_fieldoffsets = { offsetoflow32(CPUARMState, cp15.dacr_s),
153
@@ -XXX,XX +XXX,XX @@
135
offsetoflow32(CPUARMState, cp15.dacr_ns) } },
154
*/
136
- /* ARMv7 allocates a range of implementation defined TLB LOCKDOWN regs.
155
#define NPCM7XX_GCR_NR_REGS (0x148 / sizeof(uint32_t))
137
+ /*
156
138
+ * ARMv7 allocates a range of implementation defined TLB LOCKDOWN regs.
157
-typedef struct NPCM7xxGCRState {
139
* For v6 and v5, these mappings are overly broad.
158
+struct NPCM7xxGCRState {
140
*/
159
SysBusDevice parent;
141
{ .name = "TLB_LOCKDOWN", .cp = 15, .crn = 10, .crm = 0,
160
142
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v8_cp_reginfo[] = {
161
MemoryRegion iomem;
162
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxGCRState {
163
uint32_t reset_pwron;
164
uint32_t reset_mdlr;
165
uint32_t reset_intcr3;
166
-} NPCM7xxGCRState;
167
+};
168
169
#define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
170
-#define NPCM7XX_GCR(obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR)
171
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxGCRState, NPCM7XX_GCR)
172
173
#endif /* NPCM7XX_GCR_H */
174
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
175
index XXXXXXX..XXXXXXX 100644
176
--- a/include/hw/misc/npcm7xx_mft.h
177
+++ b/include/hw/misc/npcm7xx_mft.h
178
@@ -XXX,XX +XXX,XX @@
179
* @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1.
180
* @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY.
181
*/
182
-typedef struct NPCM7xxMFTState {
183
+struct NPCM7xxMFTState {
184
SysBusDevice parent;
185
186
MemoryRegion iomem;
187
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMFTState {
188
189
uint32_t max_rpm[NPCM7XX_MFT_FANIN_COUNT];
190
uint32_t duty[NPCM7XX_MFT_FANIN_COUNT];
191
-} NPCM7xxMFTState;
192
+};
193
194
#define TYPE_NPCM7XX_MFT "npcm7xx-mft"
195
-#define NPCM7XX_MFT(obj) \
196
- OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT)
197
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMFTState, NPCM7XX_MFT)
198
199
#endif /* NPCM7XX_MFT_H */
200
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
201
index XXXXXXX..XXXXXXX 100644
202
--- a/include/hw/misc/npcm7xx_pwm.h
203
+++ b/include/hw/misc/npcm7xx_pwm.h
204
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxPWMState {
143
};
205
};
144
206
145
static const ARMCPRegInfo not_v6_cp_reginfo[] = {
207
#define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
146
- /* Not all pre-v6 cores implemented this WFI, so this is slightly
208
-#define NPCM7XX_PWM(obj) \
147
+ /*
209
- OBJECT_CHECK(NPCM7xxPWMState, (obj), TYPE_NPCM7XX_PWM)
148
+ * Not all pre-v6 cores implemented this WFI, so this is slightly
210
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxPWMState, NPCM7XX_PWM)
149
* over-broad.
211
150
*/
212
#endif /* NPCM7XX_PWM_H */
151
{ .name = "WFI_v5", .cp = 15, .crn = 7, .crm = 8, .opc1 = 0, .opc2 = 2,
213
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
152
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v6_cp_reginfo[] = {
214
index XXXXXXX..XXXXXXX 100644
215
--- a/include/hw/misc/npcm7xx_rng.h
216
+++ b/include/hw/misc/npcm7xx_rng.h
217
@@ -XXX,XX +XXX,XX @@
218
219
#include "hw/sysbus.h"
220
221
-typedef struct NPCM7xxRNGState {
222
+struct NPCM7xxRNGState {
223
SysBusDevice parent;
224
225
MemoryRegion iomem;
226
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxRNGState {
227
uint8_t rngcs;
228
uint8_t rngd;
229
uint8_t rngmode;
230
-} NPCM7xxRNGState;
231
+};
232
233
#define TYPE_NPCM7XX_RNG "npcm7xx-rng"
234
-#define NPCM7XX_RNG(obj) OBJECT_CHECK(NPCM7xxRNGState, (obj), TYPE_NPCM7XX_RNG)
235
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxRNGState, NPCM7XX_RNG)
236
237
#endif /* NPCM7XX_RNG_H */
238
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
239
index XXXXXXX..XXXXXXX 100644
240
--- a/include/hw/net/npcm7xx_emc.h
241
+++ b/include/hw/net/npcm7xx_emc.h
242
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxEMCState {
243
bool rx_active;
153
};
244
};
154
245
155
static const ARMCPRegInfo not_v7_cp_reginfo[] = {
246
-typedef struct NPCM7xxEMCState NPCM7xxEMCState;
156
- /* Standard v6 WFI (also used in some pre-v6 cores); not in v7 (which
247
-
157
+ /*
248
#define TYPE_NPCM7XX_EMC "npcm7xx-emc"
158
+ * Standard v6 WFI (also used in some pre-v6 cores); not in v7 (which
249
-#define NPCM7XX_EMC(obj) \
159
* is UNPREDICTABLE; we choose to NOP as most implementations do).
250
- OBJECT_CHECK(NPCM7xxEMCState, (obj), TYPE_NPCM7XX_EMC)
160
*/
251
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxEMCState, NPCM7XX_EMC)
161
{ .name = "WFI_v6", .cp = 15, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 4,
252
162
.access = PL1_W, .type = ARM_CP_WFI },
253
#endif /* NPCM7XX_EMC_H */
163
- /* L1 cache lockdown. Not architectural in v6 and earlier but in practice
254
diff --git a/include/hw/sd/npcm7xx_sdhci.h b/include/hw/sd/npcm7xx_sdhci.h
164
+ /*
255
index XXXXXXX..XXXXXXX 100644
165
+ * L1 cache lockdown. Not architectural in v6 and earlier but in practice
256
--- a/include/hw/sd/npcm7xx_sdhci.h
166
* implemented in 926, 946, 1026, 1136, 1176 and 11MPCore. StrongARM and
257
+++ b/include/hw/sd/npcm7xx_sdhci.h
167
* OMAPCP will override this space.
258
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxRegs {
168
*/
259
uint32_t boottoctrl;
169
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo not_v7_cp_reginfo[] = {
260
} NPCM7xxRegisters;
170
{ .name = "DUMMY", .cp = 15, .crn = 0, .crm = 0, .opc1 = 1, .opc2 = CP_ANY,
261
171
.access = PL1_R, .type = ARM_CP_CONST | ARM_CP_NO_RAW,
262
-typedef struct NPCM7xxSDHCIState {
172
.resetvalue = 0 },
263
+struct NPCM7xxSDHCIState {
173
- /* We don't implement pre-v7 debug but most CPUs had at least a DBGDIDR;
264
SysBusDevice parent;
174
+ /*
265
175
+ * We don't implement pre-v7 debug but most CPUs had at least a DBGDIDR;
266
MemoryRegion container;
176
* implementing it as RAZ means the "debug architecture version" bits
267
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxSDHCIState {
177
* will read as a reserved value, which should cause Linux to not try
268
NPCM7xxRegisters regs;
178
* to use the debug hardware.
269
179
*/
270
SDHCIState sdhci;
180
{ .name = "DBGDIDR", .cp = 14, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 0,
271
-} NPCM7xxSDHCIState;
181
.access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 },
272
+};
182
- /* MMU TLB control. Note that the wildcarding means we cover not just
273
183
+ /*
274
#endif /* NPCM7XX_SDHCI_H */
184
+ * MMU TLB control. Note that the wildcarding means we cover not just
185
* the unified TLB ops but also the dside/iside/inner-shareable variants.
186
*/
187
{ .name = "TLBIALL", .cp = 15, .crn = 8, .crm = CP_ANY,
188
@@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri,
189
190
/* In ARMv8 most bits of CPACR_EL1 are RES0. */
191
if (!arm_feature(env, ARM_FEATURE_V8)) {
192
- /* ARMv7 defines bits for unimplemented coprocessors as RAZ/WI.
193
+ /*
194
+ * ARMv7 defines bits for unimplemented coprocessors as RAZ/WI.
195
* ASEDIS [31] and D32DIS [30] are both UNK/SBZP without VFP.
196
* TRCDIS [28] is RAZ/WI since we do not implement a trace macrocell.
197
*/
198
@@ -XXX,XX +XXX,XX @@ static void cpacr_write(CPUARMState *env, const ARMCPRegInfo *ri,
199
value |= R_CPACR_ASEDIS_MASK;
200
}
201
202
- /* VFPv3 and upwards with NEON implement 32 double precision
203
+ /*
204
+ * VFPv3 and upwards with NEON implement 32 double precision
205
* registers (D0-D31).
206
*/
207
if (!cpu_isar_feature(aa32_simd_r32, env_archcpu(env))) {
208
@@ -XXX,XX +XXX,XX @@ static uint64_t cpacr_read(CPUARMState *env, const ARMCPRegInfo *ri)
209
210
static void cpacr_reset(CPUARMState *env, const ARMCPRegInfo *ri)
211
{
212
- /* Call cpacr_write() so that we reset with the correct RAO bits set
213
+ /*
214
+ * Call cpacr_write() so that we reset with the correct RAO bits set
215
* for our CPU features.
216
*/
217
cpacr_write(env, ri, 0);
218
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = {
219
{ .name = "MVA_prefetch",
220
.cp = 15, .crn = 7, .crm = 13, .opc1 = 0, .opc2 = 1,
221
.access = PL1_W, .type = ARM_CP_NOP },
222
- /* We need to break the TB after ISB to execute self-modifying code
223
+ /*
224
+ * We need to break the TB after ISB to execute self-modifying code
225
* correctly and also to take any pending interrupts immediately.
226
* So use arm_cp_write_ignore() function instead of ARM_CP_NOP flag.
227
*/
228
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6_cp_reginfo[] = {
229
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.ifar_s),
230
offsetof(CPUARMState, cp15.ifar_ns) },
231
.resetvalue = 0, },
232
- /* Watchpoint Fault Address Register : should actually only be present
233
+ /*
234
+ * Watchpoint Fault Address Register : should actually only be present
235
* for 1136, 1176, 11MPCore.
236
*/
237
{ .name = "WFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1,
238
@@ -XXX,XX +XXX,XX @@ static bool event_supported(uint16_t number)
239
static CPAccessResult pmreg_access(CPUARMState *env, const ARMCPRegInfo *ri,
240
bool isread)
241
{
242
- /* Performance monitor registers user accessibility is controlled
243
+ /*
244
+ * Performance monitor registers user accessibility is controlled
245
* by PMUSERENR. MDCR_EL2.TPM and MDCR_EL3.TPM allow configurable
246
* trapping to EL2 or EL3 for other accesses.
247
*/
248
@@ -XXX,XX +XXX,XX @@ static CPAccessResult pmreg_access_ccntr(CPUARMState *env,
249
(MDCR_HPME | MDCR_HPMD | MDCR_HPMN | MDCR_HCCD | MDCR_HLP)
250
#define MDCR_EL3_PMU_ENABLE_BITS (MDCR_SPME | MDCR_SCCD)
251
252
-/* Returns true if the counter (pass 31 for PMCCNTR) should count events using
253
+/*
254
+ * Returns true if the counter (pass 31 for PMCCNTR) should count events using
255
* the current EL, security state, and register configuration.
256
*/
257
static bool pmu_counter_enabled(CPUARMState *env, uint8_t counter)
258
@@ -XXX,XX +XXX,XX @@ static uint64_t pmccntr_read(CPUARMState *env, const ARMCPRegInfo *ri)
259
static void pmselr_write(CPUARMState *env, const ARMCPRegInfo *ri,
260
uint64_t value)
261
{
262
- /* The value of PMSELR.SEL affects the behavior of PMXEVTYPER and
263
+ /*
264
+ * The value of PMSELR.SEL affects the behavior of PMXEVTYPER and
265
* PMXEVCNTR. We allow [0..31] to be written to PMSELR here; in the
266
* meanwhile, we check PMSELR.SEL when PMXEVTYPER and PMXEVCNTR are
267
* accessed.
268
@@ -XXX,XX +XXX,XX @@ static void pmevtyper_write(CPUARMState *env, const ARMCPRegInfo *ri,
269
env->cp15.c14_pmevtyper[counter] = value & PMXEVTYPER_MASK;
270
pmevcntr_op_finish(env, counter);
271
}
272
- /* Attempts to access PMXEVTYPER are CONSTRAINED UNPREDICTABLE when
273
+ /*
274
+ * Attempts to access PMXEVTYPER are CONSTRAINED UNPREDICTABLE when
275
* PMSELR value is equal to or greater than the number of implemented
276
* counters, but not equal to 0x1f. We opt to behave as a RAZ/WI.
277
*/
278
@@ -XXX,XX +XXX,XX @@ static uint64_t pmevcntr_read(CPUARMState *env, const ARMCPRegInfo *ri,
279
}
280
return ret;
281
} else {
282
- /* We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR
283
- * are CONSTRAINED UNPREDICTABLE. */
284
+ /*
285
+ * We opt to behave as a RAZ/WI when attempts to access PM[X]EVCNTR
286
+ * are CONSTRAINED UNPREDICTABLE.
287
+ */
288
return 0;
289
}
290
}
291
@@ -XXX,XX +XXX,XX @@ static void pmintenclr_write(CPUARMState *env, const ARMCPRegInfo *ri,
292
static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri,
293
uint64_t value)
294
{
295
- /* Note that even though the AArch64 view of this register has bits
296
+ /*
297
+ * Note that even though the AArch64 view of this register has bits
298
* [10:0] all RES0 we can only mask the bottom 5, to comply with the
299
* architectural requirements for bits which are RES0 only in some
300
* contexts. (ARMv8 would permit us to do no masking at all, but ARMv7
301
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
302
if (!arm_feature(env, ARM_FEATURE_EL2)) {
303
valid_mask &= ~SCR_HCE;
304
305
- /* On ARMv7, SMD (or SCD as it is called in v7) is only
306
+ /*
307
+ * On ARMv7, SMD (or SCD as it is called in v7) is only
308
* supported if EL2 exists. The bit is UNK/SBZP when
309
* EL2 is unavailable. In QEMU ARMv7, we force it to always zero
310
* when EL2 is unavailable.
311
@@ -XXX,XX +XXX,XX @@ static uint64_t ccsidr_read(CPUARMState *env, const ARMCPRegInfo *ri)
312
{
313
ARMCPU *cpu = env_archcpu(env);
314
315
- /* Acquire the CSSELR index from the bank corresponding to the CCSIDR
316
+ /*
317
+ * Acquire the CSSELR index from the bank corresponding to the CCSIDR
318
* bank
319
*/
320
uint32_t index = A32_BANKED_REG_GET(env, csselr,
321
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
322
/* the old v6 WFI, UNPREDICTABLE in v7 but we choose to NOP */
323
{ .name = "NOP", .cp = 15, .crn = 7, .crm = 0, .opc1 = 0, .opc2 = 4,
324
.access = PL1_W, .type = ARM_CP_NOP },
325
- /* Performance monitors are implementation defined in v7,
326
+ /*
327
+ * Performance monitors are implementation defined in v7,
328
* but with an ARM recommended set of registers, which we
329
* follow.
330
*
331
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
332
.writefn = csselr_write, .resetvalue = 0,
333
.bank_fieldoffsets = { offsetof(CPUARMState, cp15.csselr_s),
334
offsetof(CPUARMState, cp15.csselr_ns) } },
335
- /* Auxiliary ID register: this actually has an IMPDEF value but for now
336
+ /*
337
+ * Auxiliary ID register: this actually has an IMPDEF value but for now
338
* just RAZ for all cores:
339
*/
340
{ .name = "AIDR", .state = ARM_CP_STATE_BOTH,
341
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
342
.access = PL1_R, .type = ARM_CP_CONST,
343
.accessfn = access_aa64_tid1,
344
.resetvalue = 0 },
345
- /* Auxiliary fault status registers: these also are IMPDEF, and we
346
+ /*
347
+ * Auxiliary fault status registers: these also are IMPDEF, and we
348
* choose to RAZ/WI for all cores.
349
*/
350
{ .name = "AFSR0_EL1", .state = ARM_CP_STATE_BOTH,
351
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
352
.opc0 = 3, .opc1 = 0, .crn = 5, .crm = 1, .opc2 = 1,
353
.access = PL1_RW, .accessfn = access_tvm_trvm,
354
.type = ARM_CP_CONST, .resetvalue = 0 },
355
- /* MAIR can just read-as-written because we don't implement caches
356
+ /*
357
+ * MAIR can just read-as-written because we don't implement caches
358
* and so don't need to care about memory attributes.
359
*/
360
{ .name = "MAIR_EL1", .state = ARM_CP_STATE_AA64,
361
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v7_cp_reginfo[] = {
362
.opc0 = 3, .opc1 = 6, .crn = 10, .crm = 2, .opc2 = 0,
363
.access = PL3_RW, .fieldoffset = offsetof(CPUARMState, cp15.mair_el[3]),
364
.resetvalue = 0 },
365
- /* For non-long-descriptor page tables these are PRRR and NMRR;
366
+ /*
367
+ * For non-long-descriptor page tables these are PRRR and NMRR;
368
* regardless they still act as reads-as-written for QEMU.
369
*/
370
- /* MAIR0/1 are defined separately from their 64-bit counterpart which
371
+ /*
372
+ * MAIR0/1 are defined separately from their 64-bit counterpart which
373
* allows them to assign the correct fieldoffset based on the endianness
374
* handled in the field definitions.
375
*/
376
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v6k_cp_reginfo[] = {
377
static CPAccessResult gt_cntfrq_access(CPUARMState *env, const ARMCPRegInfo *ri,
378
bool isread)
379
{
380
- /* CNTFRQ: not visible from PL0 if both PL0PCTEN and PL0VCTEN are zero.
381
+ /*
382
+ * CNTFRQ: not visible from PL0 if both PL0PCTEN and PL0VCTEN are zero.
383
* Writable only at the highest implemented exception level.
384
*/
385
int el = arm_current_el(env);
386
@@ -XXX,XX +XXX,XX @@ static CPAccessResult gt_stimer_access(CPUARMState *env,
387
const ARMCPRegInfo *ri,
388
bool isread)
389
{
390
- /* The AArch64 register view of the secure physical timer is
391
+ /*
392
+ * The AArch64 register view of the secure physical timer is
393
* always accessible from EL3, and configurably accessible from
394
* Secure EL1.
395
*/
396
@@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx)
397
ARMGenericTimer *gt = &cpu->env.cp15.c14_timer[timeridx];
398
399
if (gt->ctl & 1) {
400
- /* Timer enabled: calculate and set current ISTATUS, irq, and
401
+ /*
402
+ * Timer enabled: calculate and set current ISTATUS, irq, and
403
* reset timer to when ISTATUS next has to change
404
*/
405
uint64_t offset = timeridx == GTIMER_VIRT ?
406
@@ -XXX,XX +XXX,XX @@ static void gt_recalc_timer(ARMCPU *cpu, int timeridx)
407
/* Next transition is when we hit cval */
408
nexttick = gt->cval + offset;
409
}
410
- /* Note that the desired next expiry time might be beyond the
411
+ /*
412
+ * Note that the desired next expiry time might be beyond the
413
* signed-64-bit range of a QEMUTimer -- in this case we just
414
* set the timer for as far in the future as possible. When the
415
* timer expires we will reset the timer for any remaining period.
416
@@ -XXX,XX +XXX,XX @@ static void gt_ctl_write(CPUARMState *env, const ARMCPRegInfo *ri,
417
/* Enable toggled */
418
gt_recalc_timer(cpu, timeridx);
419
} else if ((oldval ^ value) & 2) {
420
- /* IMASK toggled: don't need to recalculate,
421
+ /*
422
+ * IMASK toggled: don't need to recalculate,
423
* just set the interrupt line based on ISTATUS
424
*/
425
int irqstate = (oldval & 4) && !(value & 2);
426
@@ -XXX,XX +XXX,XX @@ static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaque)
427
}
428
429
static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
430
- /* Note that CNTFRQ is purely reads-as-written for the benefit
431
+ /*
432
+ * Note that CNTFRQ is purely reads-as-written for the benefit
433
* of software; writing it doesn't actually change the timer frequency.
434
* Our reset value matches the fixed frequency we implement the timer at.
435
*/
436
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
437
.readfn = gt_virt_redir_cval_read, .raw_readfn = raw_read,
438
.writefn = gt_virt_redir_cval_write, .raw_writefn = raw_write,
439
},
440
- /* Secure timer -- this is actually restricted to only EL3
441
+ /*
442
+ * Secure timer -- this is actually restricted to only EL3
443
* and configurably Secure-EL1 via the accessfn.
444
*/
445
{ .name = "CNTPS_TVAL_EL1", .state = ARM_CP_STATE_AA64,
446
@@ -XXX,XX +XXX,XX @@ static CPAccessResult e2h_access(CPUARMState *env, const ARMCPRegInfo *ri,
447
448
#else
449
450
-/* In user-mode most of the generic timer registers are inaccessible
451
+/*
452
+ * In user-mode most of the generic timer registers are inaccessible
453
* however modern kernels (4.12+) allow access to cntvct_el0
454
*/
455
456
@@ -XXX,XX +XXX,XX @@ static uint64_t gt_virt_cnt_read(CPUARMState *env, const ARMCPRegInfo *ri)
457
{
458
ARMCPU *cpu = env_archcpu(env);
459
460
- /* Currently we have no support for QEMUTimer in linux-user so we
461
+ /*
462
+ * Currently we have no support for QEMUTimer in linux-user so we
463
* can't call gt_get_countervalue(env), instead we directly
464
* call the lower level functions.
465
*/
466
@@ -XXX,XX +XXX,XX @@ static CPAccessResult ats_access(CPUARMState *env, const ARMCPRegInfo *ri,
467
bool isread)
468
{
469
if (ri->opc2 & 4) {
470
- /* The ATS12NSO* operations must trap to EL3 or EL2 if executed in
471
+ /*
472
+ * The ATS12NSO* operations must trap to EL3 or EL2 if executed in
473
* Secure EL1 (which can only happen if EL3 is AArch64).
474
* They are simply UNDEF if executed from NS EL1.
475
* They function normally from EL2 or EL3.
476
@@ -XXX,XX +XXX,XX @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
477
}
478
}
479
} else {
480
- /* fsr is a DFSR/IFSR value for the short descriptor
481
+ /*
482
+ * fsr is a DFSR/IFSR value for the short descriptor
483
* translation table format (with WnR always clear).
484
* Convert it to a 32-bit PAR.
485
*/
486
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo pmsav8r_cp_reginfo[] = {
487
};
488
489
static const ARMCPRegInfo pmsav7_cp_reginfo[] = {
490
- /* Reset for all these registers is handled in arm_cpu_reset(),
491
+ /*
492
+ * Reset for all these registers is handled in arm_cpu_reset(),
493
* because the PMSAv7 is also used by M-profile CPUs, which do
494
* not register cpregs but still need the state to be reset.
495
*/
496
@@ -XXX,XX +XXX,XX @@ static void vmsa_ttbcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
497
}
498
499
if (arm_feature(env, ARM_FEATURE_LPAE)) {
500
- /* With LPAE the TTBCR could result in a change of ASID
501
+ /*
502
+ * With LPAE the TTBCR could result in a change of ASID
503
* via the TTBCR.A1 bit, so do a TLB flush.
504
*/
505
tlb_flush(CPU(cpu));
506
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = {
507
offsetoflow32(CPUARMState, cp15.tcr_el[1])} },
508
};
509
510
-/* Note that unlike TTBCR, writing to TTBCR2 does not require flushing
511
+/*
512
+ * Note that unlike TTBCR, writing to TTBCR2 does not require flushing
513
* qemu tlbs nor adjusting cached masks.
514
*/
515
static const ARMCPRegInfo ttbcr2_reginfo = {
516
@@ -XXX,XX +XXX,XX @@ static void omap_wfi_write(CPUARMState *env, const ARMCPRegInfo *ri,
517
static void omap_cachemaint_write(CPUARMState *env, const ARMCPRegInfo *ri,
518
uint64_t value)
519
{
520
- /* On OMAP there are registers indicating the max/min index of dcache lines
521
+ /*
522
+ * On OMAP there are registers indicating the max/min index of dcache lines
523
* containing a dirty line; cache flush operations have to reset these.
524
*/
525
env->cp15.c15_i_max = 0x000;
526
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo omap_cp_reginfo[] = {
527
.crm = 8, .opc1 = 0, .opc2 = 0, .access = PL1_RW,
528
.type = ARM_CP_NO_RAW,
529
.readfn = arm_cp_read_zero, .writefn = omap_wfi_write, },
530
- /* TODO: Peripheral port remap register:
531
+ /*
532
+ * TODO: Peripheral port remap register:
533
* On OMAP2 mcr p15, 0, rn, c15, c2, 4 sets up the interrupt controller
534
* base address at $rn & ~0xfff and map size of 0x200 << ($rn & 0xfff),
535
* when MMU is off.
536
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = {
537
.cp = 15, .crn = 1, .crm = 0, .opc1 = 0, .opc2 = 1, .access = PL1_RW,
538
.fieldoffset = offsetof(CPUARMState, cp15.c1_xscaleauxcr),
539
.resetvalue = 0, },
540
- /* XScale specific cache-lockdown: since we have no cache we NOP these
541
+ /*
542
+ * XScale specific cache-lockdown: since we have no cache we NOP these
543
* and hope the guest does not really rely on cache behaviour.
544
*/
545
{ .name = "XSCALE_LOCK_ICACHE_LINE",
546
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo xscale_cp_reginfo[] = {
547
};
548
549
static const ARMCPRegInfo dummy_c15_cp_reginfo[] = {
550
- /* RAZ/WI the whole crn=15 space, when we don't have a more specific
551
+ /*
552
+ * RAZ/WI the whole crn=15 space, when we don't have a more specific
553
* implementation of this implementation-defined space.
554
* Ideally this should eventually disappear in favour of actually
555
* implementing the correct behaviour for all cores.
556
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo cache_block_ops_cp_reginfo[] = {
557
};
558
559
static const ARMCPRegInfo cache_test_clean_cp_reginfo[] = {
560
- /* The cache test-and-clean instructions always return (1 << 30)
561
+ /*
562
+ * The cache test-and-clean instructions always return (1 << 30)
563
* to indicate that there are no dirty cache lines.
564
*/
565
{ .name = "TC_DCACHE", .cp = 15, .crn = 7, .crm = 10, .opc1 = 0, .opc2 = 3,
566
@@ -XXX,XX +XXX,XX @@ static uint64_t mpidr_read_val(CPUARMState *env)
567
568
if (arm_feature(env, ARM_FEATURE_V7MP)) {
569
mpidr |= (1U << 31);
570
- /* Cores which are uniprocessor (non-coherent)
571
+ /*
572
+ * Cores which are uniprocessor (non-coherent)
573
* but still implement the MP extensions set
574
* bit 30. (For instance, Cortex-R5).
575
*/
576
@@ -XXX,XX +XXX,XX @@ static CPAccessResult access_tocu(CPUARMState *env, const ARMCPRegInfo *ri,
577
return do_cacheop_pou_access(env, HCR_TOCU | HCR_TPU);
578
}
579
580
-/* See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions
581
+/*
582
+ * See: D4.7.2 TLB maintenance requirements and the TLB maintenance instructions
583
* Page D4-1736 (DDI0487A.b)
584
*/
585
586
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_alle3is_write(CPUARMState *env, const ARMCPRegInfo *ri,
587
static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri,
588
uint64_t value)
589
{
590
- /* Invalidate by VA, EL2
591
+ /*
592
+ * Invalidate by VA, EL2
593
* Currently handles both VAE2 and VALE2, since we don't support
594
* flush-last-level-only.
595
*/
596
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae2_write(CPUARMState *env, const ARMCPRegInfo *ri,
597
static void tlbi_aa64_vae3_write(CPUARMState *env, const ARMCPRegInfo *ri,
598
uint64_t value)
599
{
600
- /* Invalidate by VA, EL3
601
+ /*
602
+ * Invalidate by VA, EL3
603
* Currently handles both VAE3 and VALE3, since we don't support
604
* flush-last-level-only.
605
*/
606
@@ -XXX,XX +XXX,XX @@ static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
607
static void tlbi_aa64_vae1_write(CPUARMState *env, const ARMCPRegInfo *ri,
608
uint64_t value)
609
{
610
- /* Invalidate by VA, EL1&0 (AArch64 version).
611
+ /*
612
+ * Invalidate by VA, EL1&0 (AArch64 version).
613
* Currently handles all of VAE1, VAAE1, VAALE1 and VALE1,
614
* since we don't support flush-for-specific-ASID-only or
615
* flush-last-level-only.
616
@@ -XXX,XX +XXX,XX @@ static CPAccessResult sp_el0_access(CPUARMState *env, const ARMCPRegInfo *ri,
617
bool isread)
618
{
619
if (!(env->pstate & PSTATE_SP)) {
620
- /* Access to SP_EL0 is undefined if it's being used as
621
+ /*
622
+ * Access to SP_EL0 is undefined if it's being used as
623
* the stack pointer.
624
*/
625
return CP_ACCESS_TRAP_UNCATEGORIZED;
626
@@ -XXX,XX +XXX,XX @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
627
}
628
629
if (raw_read(env, ri) == value) {
630
- /* Skip the TLB flush if nothing actually changed; Linux likes
631
+ /*
632
+ * Skip the TLB flush if nothing actually changed; Linux likes
633
* to do a lot of pointless SCTLR writes.
634
*/
635
return;
636
@@ -XXX,XX +XXX,XX @@ static void mdcr_el2_write(CPUARMState *env, const ARMCPRegInfo *ri,
637
}
638
639
static const ARMCPRegInfo v8_cp_reginfo[] = {
640
- /* Minimal set of EL0-visible registers. This will need to be expanded
641
+ /*
642
+ * Minimal set of EL0-visible registers. This will need to be expanded
643
* significantly for system emulation of AArch64 CPUs.
644
*/
645
{ .name = "NZCV", .state = ARM_CP_STATE_AA64,
646
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo v8_cp_reginfo[] = {
647
.opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 0,
648
.access = PL1_RW,
649
.fieldoffset = offsetof(CPUARMState, banked_spsr[BANK_SVC]) },
650
- /* We rely on the access checks not allowing the guest to write to the
651
+ /*
652
+ * We rely on the access checks not allowing the guest to write to the
653
* state field when SPSel indicates that it's being used as the stack
654
* pointer.
655
*/
656
@@ -XXX,XX +XXX,XX @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
657
if (arm_feature(env, ARM_FEATURE_EL3)) {
658
valid_mask &= ~HCR_HCD;
659
} else if (cpu->psci_conduit != QEMU_PSCI_CONDUIT_SMC) {
660
- /* Architecturally HCR.TSC is RES0 if EL3 is not implemented.
661
+ /*
662
+ * Architecturally HCR.TSC is RES0 if EL3 is not implemented.
663
* However, if we're using the SMC PSCI conduit then QEMU is
664
* effectively acting like EL3 firmware and so the guest at
665
* EL2 should retain the ability to prevent EL1 from being
666
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
667
.access = PL2_W, .type = ARM_CP_NO_RAW | ARM_CP_EL3_NO_EL2_UNDEF,
668
.writefn = tlbi_aa64_vae2is_write },
669
#ifndef CONFIG_USER_ONLY
670
- /* Unlike the other EL2-related AT operations, these must
671
+ /*
672
+ * Unlike the other EL2-related AT operations, these must
673
* UNDEF from EL3 if EL2 is not implemented, which is why we
674
* define them here rather than with the rest of the AT ops.
675
*/
676
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
677
.access = PL2_W, .accessfn = at_s1e2_access,
678
.type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC | ARM_CP_EL3_NO_EL2_UNDEF,
679
.writefn = ats_write64 },
680
- /* The AArch32 ATS1H* operations are CONSTRAINED UNPREDICTABLE
681
+ /*
682
+ * The AArch32 ATS1H* operations are CONSTRAINED UNPREDICTABLE
683
* if EL2 is not implemented; we choose to UNDEF. Behaviour at EL3
684
* with SCR.NS == 0 outside Monitor mode is UNPREDICTABLE; we choose
685
* to behave as if SCR.NS was 1.
686
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
687
.writefn = ats1h_write, .type = ARM_CP_NO_RAW | ARM_CP_RAISES_EXC },
688
{ .name = "CNTHCTL_EL2", .state = ARM_CP_STATE_BOTH,
689
.opc0 = 3, .opc1 = 4, .crn = 14, .crm = 1, .opc2 = 0,
690
- /* ARMv7 requires bit 0 and 1 to reset to 1. ARMv8 defines the
691
+ /*
692
+ * ARMv7 requires bit 0 and 1 to reset to 1. ARMv8 defines the
693
* reset values as IMPDEF. We choose to reset to 3 to comply with
694
* both ARMv7 and ARMv8.
695
*/
696
@@ -XXX,XX +XXX,XX @@ static const ARMCPRegInfo el2_sec_cp_reginfo[] = {
697
static CPAccessResult nsacr_access(CPUARMState *env, const ARMCPRegInfo *ri,
698
bool isread)
699
{
700
- /* The NSACR is RW at EL3, and RO for NS EL1 and NS EL2.
701
+ /*
702
+ * The NSACR is RW at EL3, and RO for NS EL1 and NS EL2.
703
* At Secure EL1 it traps to EL3 or EL2.
704
*/
705
if (arm_current_el(env) == 3) {
706
@@ -XXX,XX +XXX,XX @@ static void define_pmu_regs(ARMCPU *cpu)
707
}
708
}
709
710
-/* We don't know until after realize whether there's a GICv3
711
+/*
712
+ * We don't know until after realize whether there's a GICv3
713
* attached, and that is what registers the gicv3 sysregs.
714
* So we have to fill in the GIC fields in ID_PFR/ID_PFR1_EL1/ID_AA64PFR0_EL1
715
* at runtime.
716
@@ -XXX,XX +XXX,XX @@ static uint64_t id_aa64pfr0_read(CPUARMState *env, const ARMCPRegInfo *ri)
717
}
718
#endif
719
720
-/* Shared logic between LORID and the rest of the LOR* registers.
721
+/*
722
+ * Shared logic between LORID and the rest of the LOR* registers.
723
* Secure state exclusion has already been dealt with.
724
*/
725
static CPAccessResult access_lor_ns(CPUARMState *env,
726
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
727
728
define_arm_cp_regs(cpu, cp_reginfo);
729
if (!arm_feature(env, ARM_FEATURE_V8)) {
730
- /* Must go early as it is full of wildcards that may be
731
+ /*
732
+ * Must go early as it is full of wildcards that may be
733
* overridden by later definitions.
734
*/
735
define_arm_cp_regs(cpu, not_v8_cp_reginfo);
736
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
737
.access = PL1_R, .type = ARM_CP_CONST,
738
.accessfn = access_aa32_tid3,
739
.resetvalue = cpu->isar.id_pfr0 },
740
- /* ID_PFR1 is not a plain ARM_CP_CONST because we don't know
741
+ /*
742
+ * ID_PFR1 is not a plain ARM_CP_CONST because we don't know
743
* the value of the GIC field until after we define these regs.
744
*/
745
{ .name = "ID_PFR1", .state = ARM_CP_STATE_BOTH,
746
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
747
748
define_arm_cp_regs(cpu, el3_regs);
749
}
750
- /* The behaviour of NSACR is sufficiently various that we don't
751
+ /*
752
+ * The behaviour of NSACR is sufficiently various that we don't
753
* try to describe it in a single reginfo:
754
* if EL3 is 64 bit, then trap to EL3 from S EL1,
755
* reads as constant 0xc00 from NS EL1 and NS EL2
756
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
757
if (cpu_isar_feature(aa32_jazelle, cpu)) {
758
define_arm_cp_regs(cpu, jazelle_regs);
759
}
760
- /* Slightly awkwardly, the OMAP and StrongARM cores need all of
761
+ /*
762
+ * Slightly awkwardly, the OMAP and StrongARM cores need all of
763
* cp15 crn=0 to be writes-ignored, whereas for other cores they should
764
* be read-only (ie write causes UNDEF exception).
765
*/
766
{
767
ARMCPRegInfo id_pre_v8_midr_cp_reginfo[] = {
768
- /* Pre-v8 MIDR space.
769
+ /*
770
+ * Pre-v8 MIDR space.
771
* Note that the MIDR isn't a simple constant register because
772
* of the TI925 behaviour where writes to another register can
773
* cause the MIDR value to change.
774
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
775
if (arm_feature(env, ARM_FEATURE_OMAPCP) ||
776
arm_feature(env, ARM_FEATURE_STRONGARM)) {
777
size_t i;
778
- /* Register the blanket "writes ignored" value first to cover the
779
+ /*
780
+ * Register the blanket "writes ignored" value first to cover the
781
* whole space. Then update the specific ID registers to allow write
782
* access, so that they ignore writes rather than causing them to
783
* UNDEF.
784
@@ -XXX,XX +XXX,XX @@ void register_cp_regs_for_features(ARMCPU *cpu)
785
.raw_writefn = raw_write,
786
};
787
if (arm_feature(env, ARM_FEATURE_XSCALE)) {
788
- /* Normally we would always end the TB on an SCTLR write, but Linux
789
+ /*
790
+ * Normally we would always end the TB on an SCTLR write, but Linux
791
* arch/arm/mach-pxa/sleep.S expects two instructions following
792
* an MMU enable to execute from cache. Imitate this behaviour.
793
*/
794
@@ -XXX,XX +XXX,XX @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
795
void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
796
const ARMCPRegInfo *r, void *opaque)
797
{
798
- /* Define implementations of coprocessor registers.
799
+ /*
800
+ * Define implementations of coprocessor registers.
801
* We store these in a hashtable because typically
802
* there are less than 150 registers in a space which
803
* is 16*16*16*8*8 = 262144 in size.
804
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
805
default:
806
g_assert_not_reached();
807
}
808
- /* The AArch64 pseudocode CheckSystemAccess() specifies that op1
809
+ /*
810
+ * The AArch64 pseudocode CheckSystemAccess() specifies that op1
811
* encodes a minimum access level for the register. We roll this
812
* runtime check into our general permission check code, so check
813
* here that the reginfo's specified permissions are strict enough
814
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
815
assert((r->access & ~mask) == 0);
816
}
817
818
- /* Check that the register definition has enough info to handle
819
+ /*
820
+ * Check that the register definition has enough info to handle
821
* reads and writes if they are permitted.
822
*/
823
if (!(r->type & (ARM_CP_SPECIAL_MASK | ARM_CP_CONST))) {
824
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
825
continue;
826
}
827
if (state == ARM_CP_STATE_AA32) {
828
- /* Under AArch32 CP registers can be common
829
+ /*
830
+ * Under AArch32 CP registers can be common
831
* (same for secure and non-secure world) or banked.
832
*/
833
char *name;
834
@@ -XXX,XX +XXX,XX @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
835
g_assert_not_reached();
836
}
837
} else {
838
- /* AArch64 registers get mapped to non-secure instance
839
- * of AArch32 */
840
+ /*
841
+ * AArch64 registers get mapped to non-secure instance
842
+ * of AArch32
843
+ */
844
add_cpreg_to_hashtable(cpu, r, opaque, state,
845
ARM_CP_SECSTATE_NS,
846
crm, opc1, opc2, r->name);
847
@@ -XXX,XX +XXX,XX @@ void arm_cp_reset_ignore(CPUARMState *env, const ARMCPRegInfo *opaque)
848
849
static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type)
850
{
851
- /* Return true if it is not valid for us to switch to
852
+ /*
853
+ * Return true if it is not valid for us to switch to
854
* this CPU mode (ie all the UNPREDICTABLE cases in
855
* the ARM ARM CPSRWriteByInstr pseudocode).
856
*/
857
@@ -XXX,XX +XXX,XX @@ static int bad_mode_switch(CPUARMState *env, int mode, CPSRWriteType write_type)
858
case ARM_CPU_MODE_UND:
859
case ARM_CPU_MODE_IRQ:
860
case ARM_CPU_MODE_FIQ:
861
- /* Note that we don't implement the IMPDEF NSACR.RFR which in v7
862
+ /*
863
+ * Note that we don't implement the IMPDEF NSACR.RFR which in v7
864
* allows FIQ mode to be Secure-only. (In v8 this doesn't exist.)
865
*/
866
- /* If HCR.TGE is set then changes from Monitor to NS PL1 via MSR
867
+ /*
868
+ * If HCR.TGE is set then changes from Monitor to NS PL1 via MSR
869
* and CPS are treated as illegal mode changes.
870
*/
871
if (write_type == CPSRWriteByInstr &&
872
@@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
873
env->GE = (val >> 16) & 0xf;
874
}
875
876
- /* In a V7 implementation that includes the security extensions but does
877
+ /*
878
+ * In a V7 implementation that includes the security extensions but does
879
* not include Virtualization Extensions the SCR.FW and SCR.AW bits control
880
* whether non-secure software is allowed to change the CPSR_F and CPSR_A
881
* bits respectively.
882
@@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
883
changed_daif = (env->daif ^ val) & mask;
884
885
if (changed_daif & CPSR_A) {
886
- /* Check to see if we are allowed to change the masking of async
887
+ /*
888
+ * Check to see if we are allowed to change the masking of async
889
* abort exceptions from a non-secure state.
890
*/
891
if (!(env->cp15.scr_el3 & SCR_AW)) {
892
@@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
893
}
894
895
if (changed_daif & CPSR_F) {
896
- /* Check to see if we are allowed to change the masking of FIQ
897
+ /*
898
+ * Check to see if we are allowed to change the masking of FIQ
899
* exceptions from a non-secure state.
900
*/
901
if (!(env->cp15.scr_el3 & SCR_FW)) {
902
@@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
903
mask &= ~CPSR_F;
904
}
905
906
- /* Check whether non-maskable FIQ (NMFI) support is enabled.
907
+ /*
908
+ * Check whether non-maskable FIQ (NMFI) support is enabled.
909
* If this bit is set software is not allowed to mask
910
* FIQs, but is allowed to set CPSR_F to 0.
911
*/
912
@@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
913
if (write_type != CPSRWriteRaw &&
914
((env->uncached_cpsr ^ val) & mask & CPSR_M)) {
915
if ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_USR) {
916
- /* Note that we can only get here in USR mode if this is a
917
+ /*
918
+ * Note that we can only get here in USR mode if this is a
919
* gdb stub write; for this case we follow the architectural
920
* behaviour for guest writes in USR mode of ignoring an attempt
921
* to switch mode. (Those are caught by translate.c for writes
922
@@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
923
*/
924
mask &= ~CPSR_M;
925
} else if (bad_mode_switch(env, val & CPSR_M, write_type)) {
926
- /* Attempt to switch to an invalid mode: this is UNPREDICTABLE in
927
+ /*
928
+ * Attempt to switch to an invalid mode: this is UNPREDICTABLE in
929
* v7, and has defined behaviour in v8:
930
* + leave CPSR.M untouched
931
* + allow changes to the other CPSR fields
932
@@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode)
933
env->regs[14] = env->banked_r14[r14_bank_number(mode)];
934
}
935
936
-/* Physical Interrupt Target EL Lookup Table
937
+/*
938
+ * Physical Interrupt Target EL Lookup Table
939
*
940
* [ From ARM ARM section G1.13.4 (Table G1-15) ]
941
*
942
@@ -XXX,XX +XXX,XX @@ uint32_t arm_phys_excp_target_el(CPUState *cs, uint32_t excp_idx,
943
if (arm_feature(env, ARM_FEATURE_EL3)) {
944
rw = ((env->cp15.scr_el3 & SCR_RW) == SCR_RW);
945
} else {
946
- /* Either EL2 is the highest EL (and so the EL2 register width
947
+ /*
948
+ * Either EL2 is the highest EL (and so the EL2 register width
949
* is given by is64); or there is no EL2 or EL3, in which case
950
* the value of 'rw' does not affect the table lookup anyway.
951
*/
952
@@ -XXX,XX +XXX,XX @@ void aarch64_sync_64_to_32(CPUARMState *env)
953
env->banked_r13[bank_number(ARM_CPU_MODE_UND)] = env->xregs[23];
954
}
955
956
- /* Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ
957
+ /*
958
+ * Registers x24-x30 are mapped to r8-r14 in FIQ mode. If we are in FIQ
959
* mode, then we can copy to r8-r14. Otherwise, we copy to the
960
* FIQ bank for r8-r14.
961
*/
962
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
963
/* High vectors. When enabled, base address cannot be remapped. */
964
addr += 0xffff0000;
965
} else {
966
- /* ARM v7 architectures provide a vector base address register to remap
967
+ /*
968
+ * ARM v7 architectures provide a vector base address register to remap
969
* the interrupt vector table.
970
* This register is only followed in non-monitor mode, and is banked.
971
* Note: only bits 31:5 are valid.
972
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
973
aarch64_sve_change_el(env, cur_el, new_el, is_a64(env));
974
975
if (cur_el < new_el) {
976
- /* Entry vector offset depends on whether the implemented EL
977
+ /*
978
+ * Entry vector offset depends on whether the implemented EL
979
* immediately lower than the target level is using AArch32 or AArch64
980
*/
981
bool is_aa64;
982
@@ -XXX,XX +XXX,XX @@ static void handle_semihosting(CPUState *cs)
983
}
984
#endif
985
986
-/* Handle a CPU exception for A and R profile CPUs.
987
+/*
988
+ * Handle a CPU exception for A and R profile CPUs.
989
* Do any appropriate logging, handle PSCI calls, and then hand off
990
* to the AArch64-entry or AArch32-entry function depending on the
991
* target exception level's register width.
992
@@ -XXX,XX +XXX,XX @@ void arm_cpu_do_interrupt(CPUState *cs)
993
}
994
#endif
995
996
- /* Hooks may change global state so BQL should be held, also the
997
+ /*
998
+ * Hooks may change global state so BQL should be held, also the
999
* BQL needs to be held for any modification of
1000
* cs->interrupt_request.
1001
*/
1002
@@ -XXX,XX +XXX,XX @@ ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
1003
};
1004
}
1005
1006
-/* Note that signed overflow is undefined in C. The following routines are
1007
- careful to use unsigned types where modulo arithmetic is required.
1008
- Failure to do so _will_ break on newer gcc. */
1009
+/*
1010
+ * Note that signed overflow is undefined in C. The following routines are
1011
+ * careful to use unsigned types where modulo arithmetic is required.
1012
+ * Failure to do so _will_ break on newer gcc.
1013
+ */
1014
1015
/* Signed saturating arithmetic. */
1016
1017
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b)
1018
return (a & mask) | (b & ~mask);
1019
}
1020
1021
-/* CRC helpers.
1022
+/*
1023
+ * CRC helpers.
1024
* The upper bytes of val (above the number specified by 'bytes') must have
1025
* been zeroed out by the caller.
1026
*/
1027
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes)
1028
return crc32c(acc, buf, bytes) ^ 0xffffffff;
1029
}
1030
1031
-/* Return the exception level to which FP-disabled exceptions should
1032
+/*
1033
+ * Return the exception level to which FP-disabled exceptions should
1034
* be taken, or 0 if FP is enabled.
1035
*/
1036
int fp_exception_el(CPUARMState *env, int cur_el)
1037
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
1038
#ifndef CONFIG_USER_ONLY
1039
uint64_t hcr_el2;
1040
1041
- /* CPACR and the CPTR registers don't exist before v6, so FP is
1042
+ /*
1043
+ * CPACR and the CPTR registers don't exist before v6, so FP is
1044
* always accessible
1045
*/
1046
if (!arm_feature(env, ARM_FEATURE_V6)) {
1047
@@ -XXX,XX +XXX,XX @@ int fp_exception_el(CPUARMState *env, int cur_el)
1048
1049
hcr_el2 = arm_hcr_el2_eff(env);
1050
1051
- /* The CPACR controls traps to EL1, or PL1 if we're 32 bit:
1052
+ /*
1053
+ * The CPACR controls traps to EL1, or PL1 if we're 32 bit:
1054
* 0, 2 : trap EL0 and EL1/PL1 accesses
1055
* 1 : trap only EL0 accesses
1056
* 3 : trap no accesses
1057
--
275
--
1058
2.25.1
276
2.34.1
277
278
diff view generated by jsdifflib
1
From: Axel Heider <axel.heider@hensoldt.net>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
- fix #1263 for CR writes
3
The structure is named SECUREECState. Rename the type accordingly.
4
- rework compare time handling
5
- The compare timer has to run even if CR.OCIEN is not set,
6
as SR.OCIF must be updated.
7
- The compare timer fires exactly once when the
8
compare value is less than the current value, but the
9
reload values is less than the compare value.
10
- The compare timer will never fire if the reload value is
11
less than the compare value. Disable it in this case.
12
4
13
Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
14
[PMM: fixed minor style nits]
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
15
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
Message-id: 20230109140306.23161-12-philmd@linaro.org
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
9
---
18
hw/timer/imx_epit.c | 192 ++++++++++++++++++++++++++------------------
10
hw/misc/sbsa_ec.c | 13 +++++++------
19
1 file changed, 116 insertions(+), 76 deletions(-)
11
1 file changed, 7 insertions(+), 6 deletions(-)
20
12
21
diff --git a/hw/timer/imx_epit.c b/hw/timer/imx_epit.c
13
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
22
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/timer/imx_epit.c
15
--- a/hw/misc/sbsa_ec.c
24
+++ b/hw/timer/imx_epit.c
16
+++ b/hw/misc/sbsa_ec.c
25
@@ -XXX,XX +XXX,XX @@
17
@@ -XXX,XX +XXX,XX @@
26
* Originally written by Hans Jiang
18
#include "hw/sysbus.h"
27
* Updated by Peter Chubb
19
#include "sysemu/runstate.h"
28
* Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
20
29
+ * Updated by Axel Heider
21
-typedef struct {
30
*
22
+typedef struct SECUREECState {
31
* This code is licensed under GPL version 2 or later. See
23
SysBusDevice parent_obj;
32
* the COPYING file in the top-level directory.
24
MemoryRegion iomem;
33
@@ -XXX,XX +XXX,XX @@ static uint64_t imx_epit_read(void *opaque, hwaddr offset, unsigned size)
25
} SECUREECState;
34
return reg_value;
26
27
-#define TYPE_SBSA_EC "sbsa-ec"
28
-#define SECURE_EC(obj) OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_EC)
29
+#define TYPE_SBSA_SECURE_EC "sbsa-ec"
30
+#define SBSA_SECURE_EC(obj) \
31
+ OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_SECURE_EC)
32
33
enum sbsa_ec_powerstates {
34
SBSA_EC_CMD_POWEROFF = 0x01,
35
@@ -XXX,XX +XXX,XX @@ static uint64_t sbsa_ec_read(void *opaque, hwaddr offset, unsigned size)
35
}
36
}
36
37
37
-/* Must be called from ptimer_transaction_begin/commit block for s->timer_cmp */
38
static void sbsa_ec_write(void *opaque, hwaddr offset,
38
-static void imx_epit_reload_compare_timer(IMXEPITState *s)
39
- uint64_t value, unsigned size)
39
+/*
40
+ uint64_t value, unsigned size)
40
+ * Must be called from a ptimer_transaction_begin/commit block for
41
+ * s->timer_cmp, but outside of a transaction block of s->timer_reload,
42
+ * so the proper counter value is read.
43
+ */
44
+static void imx_epit_update_compare_timer(IMXEPITState *s)
45
{
41
{
46
- if ((s->cr & (CR_EN | CR_OCIEN)) == (CR_EN | CR_OCIEN)) {
42
if (offset == 0) { /* PSCI machine power command register */
47
- /* if the compare feature is on and timers are running */
43
switch (value) {
48
- uint32_t tmp = ptimer_get_count(s->timer_reload);
44
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps sbsa_ec_ops = {
49
- uint64_t next;
45
50
- if (tmp > s->cmp) {
46
static void sbsa_ec_init(Object *obj)
51
- /* It'll fire in this round of the timer */
47
{
52
- next = tmp - s->cmp;
48
- SECUREECState *s = SECURE_EC(obj);
53
- } else { /* catch it next time around */
49
+ SECUREECState *s = SBSA_SECURE_EC(obj);
54
- next = tmp - s->cmp + ((s->cr & CR_RLD) ? EPIT_TIMER_MAX : s->lr);
50
SysBusDevice *dev = SYS_BUS_DEVICE(obj);
55
+ uint64_t counter = 0;
51
56
+ bool is_oneshot = false;
52
memory_region_init_io(&s->iomem, obj, &sbsa_ec_ops, s, "sbsa-ec",
57
+ /*
53
@@ -XXX,XX +XXX,XX @@ static void sbsa_ec_class_init(ObjectClass *klass, void *data)
58
+ * The compare timer only has to run if the timer peripheral is active
59
+ * and there is an input clock, Otherwise it can be switched off.
60
+ */
61
+ bool is_active = (s->cr & CR_EN) && imx_epit_get_freq(s);
62
+ if (is_active) {
63
+ /*
64
+ * Calculate next timeout for compare timer. Reading the reload
65
+ * counter returns proper results only if pending transactions
66
+ * on it are committed here. Otherwise stale values are be read.
67
+ */
68
+ counter = ptimer_get_count(s->timer_reload);
69
+ uint64_t limit = ptimer_get_limit(s->timer_cmp);
70
+ /*
71
+ * The compare timer is a periodic timer if the limit is at least
72
+ * the compare value. Otherwise it may fire at most once in the
73
+ * current round.
74
+ */
75
+ bool is_oneshot = (limit >= s->cmp);
76
+ if (counter >= s->cmp) {
77
+ /* The compare timer fires in the current round. */
78
+ counter -= s->cmp;
79
+ } else if (!is_oneshot) {
80
+ /*
81
+ * The compare timer fires after a reload, as it is below the
82
+ * compare value already in this round. Note that the counter
83
+ * value calculated below can be above the 32-bit limit, which
84
+ * is legal here because the compare timer is an internal
85
+ * helper ptimer only.
86
+ */
87
+ counter += limit - s->cmp;
88
+ } else {
89
+ /*
90
+ * The compare timer won't fire in this round, and the limit is
91
+ * set to a value below the compare value. This practically means
92
+ * it will never fire, so it can be switched off.
93
+ */
94
+ is_active = false;
95
}
96
- ptimer_set_count(s->timer_cmp, next);
97
}
98
+
99
+ /*
100
+ * Set the compare timer and let it run, or stop it. This is agnostic
101
+ * of CR.OCIEN bit, as this bit affects interrupt generation only. The
102
+ * compare timer needs to run even if no interrupts are to be generated,
103
+ * because the SR.OCIF bit must be updated also.
104
+ * Note that the timer might already be stopped or be running with
105
+ * counter values. However, finding out when an update is needed and
106
+ * when not is not trivial. It's much easier applying the setting again,
107
+ * as this does not harm either and the overhead is negligible.
108
+ */
109
+ if (is_active) {
110
+ ptimer_set_count(s->timer_cmp, counter);
111
+ ptimer_run(s->timer_cmp, is_oneshot ? 1 : 0);
112
+ } else {
113
+ ptimer_stop(s->timer_cmp);
114
+ }
115
+
116
}
54
}
117
55
118
static void imx_epit_write_cr(IMXEPITState *s, uint32_t value)
56
static const TypeInfo sbsa_ec_info = {
119
{
57
- .name = TYPE_SBSA_EC,
120
- uint32_t freq = 0;
58
+ .name = TYPE_SBSA_SECURE_EC,
121
uint32_t oldcr = s->cr;
59
.parent = TYPE_SYS_BUS_DEVICE,
122
60
.instance_size = sizeof(SECUREECState),
123
s->cr = value & 0x03ffffff;
61
.instance_init = sbsa_ec_init,
124
125
if (s->cr & CR_SWR) {
126
- /* handle the reset */
127
+ /*
128
+ * Reset clears CR.SWR again. It does not touch CR.EN, but the timers
129
+ * are still stopped because the input clock is disabled.
130
+ */
131
imx_epit_reset(s, false);
132
+ } else {
133
+ uint32_t freq;
134
+ uint32_t toggled_cr_bits = oldcr ^ s->cr;
135
+ /* re-initialize the limits if CR.RLD has changed */
136
+ bool set_limit = toggled_cr_bits & CR_RLD;
137
+ /* set the counter if the timer got just enabled and CR.ENMOD is set */
138
+ bool is_switched_on = (toggled_cr_bits & s->cr) & CR_EN;
139
+ bool set_counter = is_switched_on && (s->cr & CR_ENMOD);
140
+
141
+ ptimer_transaction_begin(s->timer_cmp);
142
+ ptimer_transaction_begin(s->timer_reload);
143
+ freq = imx_epit_get_freq(s);
144
+ if (freq) {
145
+ ptimer_set_freq(s->timer_reload, freq);
146
+ ptimer_set_freq(s->timer_cmp, freq);
147
+ }
148
+
149
+ if (set_limit || set_counter) {
150
+ uint64_t limit = (s->cr & CR_RLD) ? s->lr : EPIT_TIMER_MAX;
151
+ ptimer_set_limit(s->timer_reload, limit, set_counter ? 1 : 0);
152
+ if (set_limit) {
153
+ ptimer_set_limit(s->timer_cmp, limit, 0);
154
+ }
155
+ }
156
+ /*
157
+ * If there is an input clock and the peripheral is enabled, then
158
+ * ensure the wall clock timer is ticking. Otherwise stop the timers.
159
+ * The compare timer will be updated later.
160
+ */
161
+ if (freq && (s->cr & CR_EN)) {
162
+ ptimer_run(s->timer_reload, 0);
163
+ } else {
164
+ ptimer_stop(s->timer_reload);
165
+ }
166
+ /* Commit changes to reload timer, so they can propagate. */
167
+ ptimer_transaction_commit(s->timer_reload);
168
+ /* Update compare timer based on the committed reload timer value. */
169
+ imx_epit_update_compare_timer(s);
170
+ ptimer_transaction_commit(s->timer_cmp);
171
}
172
173
/*
174
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write_cr(IMXEPITState *s, uint32_t value)
175
* - write to CR.EN or CR.OCIE
176
*/
177
imx_epit_update_int(s);
178
-
179
- /*
180
- * TODO: could we 'break' here for reset? following operations appear
181
- * to duplicate the work imx_epit_reset() already did.
182
- */
183
-
184
- ptimer_transaction_begin(s->timer_cmp);
185
- ptimer_transaction_begin(s->timer_reload);
186
-
187
- /*
188
- * Update the frequency. In case of a reset the input clock was
189
- * switched off, so this can be skipped.
190
- */
191
- if (!(s->cr & CR_SWR)) {
192
- freq = imx_epit_get_freq(s);
193
- if (freq) {
194
- ptimer_set_freq(s->timer_reload, freq);
195
- ptimer_set_freq(s->timer_cmp, freq);
196
- }
197
- }
198
-
199
- if (freq && (s->cr & CR_EN) && !(oldcr & CR_EN)) {
200
- if (s->cr & CR_ENMOD) {
201
- if (s->cr & CR_RLD) {
202
- ptimer_set_limit(s->timer_reload, s->lr, 1);
203
- ptimer_set_limit(s->timer_cmp, s->lr, 1);
204
- } else {
205
- ptimer_set_limit(s->timer_reload, EPIT_TIMER_MAX, 1);
206
- ptimer_set_limit(s->timer_cmp, EPIT_TIMER_MAX, 1);
207
- }
208
- }
209
-
210
- imx_epit_reload_compare_timer(s);
211
- ptimer_run(s->timer_reload, 0);
212
- if (s->cr & CR_OCIEN) {
213
- ptimer_run(s->timer_cmp, 0);
214
- } else {
215
- ptimer_stop(s->timer_cmp);
216
- }
217
- } else if (!(s->cr & CR_EN)) {
218
- /* stop both timers */
219
- ptimer_stop(s->timer_reload);
220
- ptimer_stop(s->timer_cmp);
221
- } else if (s->cr & CR_OCIEN) {
222
- if (!(oldcr & CR_OCIEN)) {
223
- imx_epit_reload_compare_timer(s);
224
- ptimer_run(s->timer_cmp, 0);
225
- }
226
- } else {
227
- ptimer_stop(s->timer_cmp);
228
- }
229
-
230
- ptimer_transaction_commit(s->timer_cmp);
231
- ptimer_transaction_commit(s->timer_reload);
232
}
233
234
static void imx_epit_write_sr(IMXEPITState *s, uint32_t value)
235
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write_lr(IMXEPITState *s, uint32_t value)
236
/* If IOVW bit is set then set the timer value */
237
ptimer_set_count(s->timer_reload, s->lr);
238
}
239
- /*
240
- * Commit the change to s->timer_reload, so it can propagate. Otherwise
241
- * the timer interrupt may not fire properly. The commit must happen
242
- * before calling imx_epit_reload_compare_timer(), which reads
243
- * s->timer_reload internally again.
244
- */
245
+ /* Commit the changes to s->timer_reload, so they can propagate. */
246
ptimer_transaction_commit(s->timer_reload);
247
- imx_epit_reload_compare_timer(s);
248
+ /* Update the compare timer based on the committed reload timer value. */
249
+ imx_epit_update_compare_timer(s);
250
ptimer_transaction_commit(s->timer_cmp);
251
}
252
253
@@ -XXX,XX +XXX,XX @@ static void imx_epit_write_cmp(IMXEPITState *s, uint32_t value)
254
{
255
s->cmp = value;
256
257
+ /* Update the compare timer based on the committed reload timer value. */
258
ptimer_transaction_begin(s->timer_cmp);
259
- imx_epit_reload_compare_timer(s);
260
+ imx_epit_update_compare_timer(s);
261
ptimer_transaction_commit(s->timer_cmp);
262
}
263
264
@@ -XXX,XX +XXX,XX @@ static void imx_epit_cmp(void *opaque)
265
{
266
IMXEPITState *s = IMX_EPIT(opaque);
267
268
+ /* The cmp ptimer can't be running when the peripheral is disabled */
269
+ assert(s->cr & CR_EN);
270
+
271
DPRINTF("sr was %d\n", s->sr);
272
/* Set interrupt status bit SR.OCIF and update the interrupt state */
273
s->sr |= SR_OCIF;
274
--
62
--
275
2.25.1
63
2.34.1
64
65
diff view generated by jsdifflib
1
From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The v8R PMSAv8 has a two-stage MPU translation process, but, unlike
3
This model was merged few days before the QOM cleanup from
4
VMSAv8, the stage 2 attributes are in the same format as the stage 1
4
commit 8063396bf3 ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible")
5
attributes (8-bit MAIR format). Rather than converting the MAIR
5
was pulled and merged. Manually adapt.
6
format to the format used for VMSA stage 2 (bits [5:2] of a VMSA
7
stage 2 descriptor) and then converting back to do the attribute
8
combination, allow combined_attrs_nofwb() to accept s2 attributes
9
that are already in the MAIR format.
10
6
11
We move the assert() to combined_attrs_fwb(), because that function
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
really does require a VMSA stage 2 attribute format. (We will never
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
get there for v8R, because PMSAv8 does not implement FEAT_S2FWB.)
9
Message-id: 20230109140306.23161-13-philmd@linaro.org
14
15
Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
16
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
17
Message-id: 20221206102504.165775-4-tobias.roehmel@rwth-aachen.de
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
19
---
11
---
20
target/arm/ptw.c | 10 ++++++++--
12
hw/misc/sbsa_ec.c | 3 +--
21
1 file changed, 8 insertions(+), 2 deletions(-)
13
1 file changed, 1 insertion(+), 2 deletions(-)
22
14
23
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
15
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
24
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
25
--- a/target/arm/ptw.c
17
--- a/hw/misc/sbsa_ec.c
26
+++ b/target/arm/ptw.c
18
+++ b/hw/misc/sbsa_ec.c
27
@@ -XXX,XX +XXX,XX @@ static uint8_t combined_attrs_nofwb(uint64_t hcr,
19
@@ -XXX,XX +XXX,XX @@ typedef struct SECUREECState {
28
{
20
} SECUREECState;
29
uint8_t s1lo, s2lo, s1hi, s2hi, s2_mair_attrs, ret_attrs;
21
30
22
#define TYPE_SBSA_SECURE_EC "sbsa-ec"
31
- s2_mair_attrs = convert_stage2_attrs(hcr, s2.attrs);
23
-#define SBSA_SECURE_EC(obj) \
32
+ if (s2.is_s2_format) {
24
- OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_SECURE_EC)
33
+ s2_mair_attrs = convert_stage2_attrs(hcr, s2.attrs);
25
+OBJECT_DECLARE_SIMPLE_TYPE(SECUREECState, SBSA_SECURE_EC)
34
+ } else {
26
35
+ s2_mair_attrs = s2.attrs;
27
enum sbsa_ec_powerstates {
36
+ }
28
SBSA_EC_CMD_POWEROFF = 0x01,
37
38
s1lo = extract32(s1.attrs, 0, 4);
39
s2lo = extract32(s2_mair_attrs, 0, 4);
40
@@ -XXX,XX +XXX,XX @@ static uint8_t force_cacheattr_nibble_wb(uint8_t attr)
41
*/
42
static uint8_t combined_attrs_fwb(ARMCacheAttrs s1, ARMCacheAttrs s2)
43
{
44
+ assert(s2.is_s2_format && !s1.is_s2_format);
45
+
46
switch (s2.attrs) {
47
case 7:
48
/* Use stage 1 attributes */
49
@@ -XXX,XX +XXX,XX @@ static ARMCacheAttrs combine_cacheattrs(uint64_t hcr,
50
ARMCacheAttrs ret;
51
bool tagged = false;
52
53
- assert(s2.is_s2_format && !s1.is_s2_format);
54
+ assert(!s1.is_s2_format);
55
ret.is_s2_format = false;
56
57
if (s1.attrs == 0xf0) {
58
--
29
--
59
2.25.1
30
2.34.1
60
31
61
32
diff view generated by jsdifflib
1
From: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Add PMSAv8r translation.
3
This remove a use of 'struct' in the DECLARE_INSTANCE_CHECKER()
4
macro call, to avoid after a QOM refactor:
4
5
5
Signed-off-by: Tobias Röhmel <tobias.roehmel@rwth-aachen.de>
6
hw/intc/xilinx_intc.c:45:1: error: declaration of anonymous struct must be a definition
6
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7
DECLARE_INSTANCE_CHECKER(struct xlx_pic, XILINX_INTC,
7
Message-id: 20221206102504.165775-7-tobias.roehmel@rwth-aachen.de
8
^
9
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
12
Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com>
13
Message-id: 20230109140306.23161-14-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
15
---
10
target/arm/ptw.c | 126 ++++++++++++++++++++++++++++++++++++++---------
16
hw/intc/xilinx_intc.c | 28 +++++++++++++---------------
11
1 file changed, 104 insertions(+), 22 deletions(-)
17
1 file changed, 13 insertions(+), 15 deletions(-)
12
18
13
diff --git a/target/arm/ptw.c b/target/arm/ptw.c
19
diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c
14
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
15
--- a/target/arm/ptw.c
21
--- a/hw/intc/xilinx_intc.c
16
+++ b/target/arm/ptw.c
22
+++ b/hw/intc/xilinx_intc.c
17
@@ -XXX,XX +XXX,XX @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
23
@@ -XXX,XX +XXX,XX @@
18
24
#define R_MAX 8
19
if (arm_feature(env, ARM_FEATURE_M)) {
25
20
return env->v7m.mpu_ctrl[is_secure] & R_V7M_MPU_CTRL_PRIVDEFENA_MASK;
26
#define TYPE_XILINX_INTC "xlnx.xps-intc"
21
- } else {
27
-DECLARE_INSTANCE_CHECKER(struct xlx_pic, XILINX_INTC,
22
- return regime_sctlr(env, mmu_idx) & SCTLR_BR;
28
- TYPE_XILINX_INTC)
23
}
29
+typedef struct XpsIntc XpsIntc;
24
+
30
+DECLARE_INSTANCE_CHECKER(XpsIntc, XILINX_INTC, TYPE_XILINX_INTC)
25
+ if (mmu_idx == ARMMMUIdx_Stage2) {
31
26
+ return false;
32
-struct xlx_pic
27
+ }
33
+struct XpsIntc
28
+
34
{
29
+ return regime_sctlr(env, mmu_idx) & SCTLR_BR;
35
SysBusDevice parent_obj;
36
37
@@ -XXX,XX +XXX,XX @@ struct xlx_pic
38
uint32_t irq_pin_state;
39
};
40
41
-static void update_irq(struct xlx_pic *p)
42
+static void update_irq(XpsIntc *p)
43
{
44
uint32_t i;
45
46
@@ -XXX,XX +XXX,XX @@ static void update_irq(struct xlx_pic *p)
47
qemu_set_irq(p->parent_irq, (p->regs[R_MER] & 1) && p->regs[R_IPR]);
30
}
48
}
31
49
32
static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
50
-static uint64_t
33
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_pmsav7(CPUARMState *env, uint32_t address,
51
-pic_read(void *opaque, hwaddr addr, unsigned int size)
34
return !(result->f.prot & (1 << access_type));
52
+static uint64_t pic_read(void *opaque, hwaddr addr, unsigned int size)
53
{
54
- struct xlx_pic *p = opaque;
55
+ XpsIntc *p = opaque;
56
uint32_t r = 0;
57
58
addr >>= 2;
59
@@ -XXX,XX +XXX,XX @@ pic_read(void *opaque, hwaddr addr, unsigned int size)
60
return r;
35
}
61
}
36
62
37
+static uint32_t *regime_rbar(CPUARMState *env, ARMMMUIdx mmu_idx,
63
-static void
38
+ uint32_t secure)
64
-pic_write(void *opaque, hwaddr addr,
39
+{
65
- uint64_t val64, unsigned int size)
40
+ if (regime_el(env, mmu_idx) == 2) {
66
+static void pic_write(void *opaque, hwaddr addr,
41
+ return env->pmsav8.hprbar;
67
+ uint64_t val64, unsigned int size)
42
+ } else {
68
{
43
+ return env->pmsav8.rbar[secure];
69
- struct xlx_pic *p = opaque;
44
+ }
70
+ XpsIntc *p = opaque;
45
+}
71
uint32_t value = val64;
46
+
72
47
+static uint32_t *regime_rlar(CPUARMState *env, ARMMMUIdx mmu_idx,
73
addr >>= 2;
48
+ uint32_t secure)
74
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps pic_ops = {
49
+{
75
50
+ if (regime_el(env, mmu_idx) == 2) {
76
static void irq_handler(void *opaque, int irq, int level)
51
+ return env->pmsav8.hprlar;
77
{
52
+ } else {
78
- struct xlx_pic *p = opaque;
53
+ return env->pmsav8.rlar[secure];
79
+ XpsIntc *p = opaque;
54
+ }
80
55
+}
81
/* edge triggered interrupt */
56
+
82
if (p->c_kind_of_intr & (1 << irq) && p->regs[R_MER] & 2) {
57
bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
83
@@ -XXX,XX +XXX,XX @@ static void irq_handler(void *opaque, int irq, int level)
58
MMUAccessType access_type, ARMMMUIdx mmu_idx,
84
59
bool secure, GetPhysAddrResult *result,
85
static void xilinx_intc_init(Object *obj)
60
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
86
{
61
bool hit = false;
87
- struct xlx_pic *p = XILINX_INTC(obj);
62
uint32_t addr_page_base = address & TARGET_PAGE_MASK;
88
+ XpsIntc *p = XILINX_INTC(obj);
63
uint32_t addr_page_limit = addr_page_base + (TARGET_PAGE_SIZE - 1);
89
64
+ int region_counter;
90
qdev_init_gpio_in(DEVICE(obj), irq_handler, 32);
65
+
91
sysbus_init_irq(SYS_BUS_DEVICE(obj), &p->parent_irq);
66
+ if (regime_el(env, mmu_idx) == 2) {
92
@@ -XXX,XX +XXX,XX @@ static void xilinx_intc_init(Object *obj)
67
+ region_counter = cpu->pmsav8r_hdregion;
68
+ } else {
69
+ region_counter = cpu->pmsav7_dregion;
70
+ }
71
72
result->f.lg_page_size = TARGET_PAGE_BITS;
73
result->f.phys_addr = address;
74
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
75
*mregion = -1;
76
}
77
78
+ if (mmu_idx == ARMMMUIdx_Stage2) {
79
+ fi->stage2 = true;
80
+ }
81
+
82
/*
83
* Unlike the ARM ARM pseudocode, we don't need to check whether this
84
* was an exception vector read from the vector table (which is always
85
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
86
hit = true;
87
}
88
89
- for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
90
+ uint32_t bitmask;
91
+ if (arm_feature(env, ARM_FEATURE_M)) {
92
+ bitmask = 0x1f;
93
+ } else {
94
+ bitmask = 0x3f;
95
+ fi->level = 0;
96
+ }
97
+
98
+ for (n = region_counter - 1; n >= 0; n--) {
99
/* region search */
100
/*
101
- * Note that the base address is bits [31:5] from the register
102
- * with bits [4:0] all zeroes, but the limit address is bits
103
- * [31:5] from the register with bits [4:0] all ones.
104
+ * Note that the base address is bits [31:x] from the register
105
+ * with bits [x-1:0] all zeroes, but the limit address is bits
106
+ * [31:x] from the register with bits [x:0] all ones. Where x is
107
+ * 5 for Cortex-M and 6 for Cortex-R
108
*/
109
- uint32_t base = env->pmsav8.rbar[secure][n] & ~0x1f;
110
- uint32_t limit = env->pmsav8.rlar[secure][n] | 0x1f;
111
+ uint32_t base = regime_rbar(env, mmu_idx, secure)[n] & ~bitmask;
112
+ uint32_t limit = regime_rlar(env, mmu_idx, secure)[n] | bitmask;
113
114
- if (!(env->pmsav8.rlar[secure][n] & 0x1)) {
115
+ if (!(regime_rlar(env, mmu_idx, secure)[n] & 0x1)) {
116
/* Region disabled */
117
continue;
118
}
119
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
120
* PMSAv7 where highest-numbered-region wins)
121
*/
122
fi->type = ARMFault_Permission;
123
- fi->level = 1;
124
+ if (arm_feature(env, ARM_FEATURE_M)) {
125
+ fi->level = 1;
126
+ }
127
return true;
128
}
129
130
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
131
}
132
133
if (!hit) {
134
- /* background fault */
135
- fi->type = ARMFault_Background;
136
+ if (arm_feature(env, ARM_FEATURE_M)) {
137
+ fi->type = ARMFault_Background;
138
+ } else {
139
+ fi->type = ARMFault_Permission;
140
+ }
141
return true;
142
}
143
144
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
145
/* hit using the background region */
146
get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->f.prot);
147
} else {
148
- uint32_t ap = extract32(env->pmsav8.rbar[secure][matchregion], 1, 2);
149
- uint32_t xn = extract32(env->pmsav8.rbar[secure][matchregion], 0, 1);
150
+ uint32_t matched_rbar = regime_rbar(env, mmu_idx, secure)[matchregion];
151
+ uint32_t matched_rlar = regime_rlar(env, mmu_idx, secure)[matchregion];
152
+ uint32_t ap = extract32(matched_rbar, 1, 2);
153
+ uint32_t xn = extract32(matched_rbar, 0, 1);
154
bool pxn = false;
155
156
if (arm_feature(env, ARM_FEATURE_V8_1M)) {
157
- pxn = extract32(env->pmsav8.rlar[secure][matchregion], 4, 1);
158
+ pxn = extract32(matched_rlar, 4, 1);
159
}
160
161
if (m_is_system_region(env, address)) {
162
@@ -XXX,XX +XXX,XX @@ bool pmsav8_mpu_lookup(CPUARMState *env, uint32_t address,
163
xn = 1;
164
}
165
166
- result->f.prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
167
+ if (regime_el(env, mmu_idx) == 2) {
168
+ result->f.prot = simple_ap_to_rw_prot_is_user(ap,
169
+ mmu_idx != ARMMMUIdx_E2);
170
+ } else {
171
+ result->f.prot = simple_ap_to_rw_prot(env, mmu_idx, ap);
172
+ }
173
+
174
+ if (!arm_feature(env, ARM_FEATURE_M)) {
175
+ uint8_t attrindx = extract32(matched_rlar, 1, 3);
176
+ uint64_t mair = env->cp15.mair_el[regime_el(env, mmu_idx)];
177
+ uint8_t sh = extract32(matched_rlar, 3, 2);
178
+
179
+ if (regime_sctlr(env, mmu_idx) & SCTLR_WXN &&
180
+ result->f.prot & PAGE_WRITE && mmu_idx != ARMMMUIdx_Stage2) {
181
+ xn = 0x1;
182
+ }
183
+
184
+ if ((regime_el(env, mmu_idx) == 1) &&
185
+ regime_sctlr(env, mmu_idx) & SCTLR_UWXN && ap == 0x1) {
186
+ pxn = 0x1;
187
+ }
188
+
189
+ result->cacheattrs.is_s2_format = false;
190
+ result->cacheattrs.attrs = extract64(mair, attrindx * 8, 8);
191
+ result->cacheattrs.shareability = sh;
192
+ }
193
+
194
if (result->f.prot && !xn && !(pxn && !is_user)) {
195
result->f.prot |= PAGE_EXEC;
196
}
197
- /*
198
- * We don't need to look the attribute up in the MAIR0/MAIR1
199
- * registers because that only tells us about cacheability.
200
- */
201
+
202
if (mregion) {
203
*mregion = matchregion;
204
}
205
}
206
207
fi->type = ARMFault_Permission;
208
- fi->level = 1;
209
+ if (arm_feature(env, ARM_FEATURE_M)) {
210
+ fi->level = 1;
211
+ }
212
return !(result->f.prot & (1 << access_type));
213
}
93
}
214
94
215
@@ -XXX,XX +XXX,XX @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
95
static Property xilinx_intc_properties[] = {
216
cacheattrs1 = result->cacheattrs;
96
- DEFINE_PROP_UINT32("kind-of-intr", struct xlx_pic, c_kind_of_intr, 0),
217
memset(result, 0, sizeof(*result));
97
+ DEFINE_PROP_UINT32("kind-of-intr", XpsIntc, c_kind_of_intr, 0),
218
98
DEFINE_PROP_END_OF_LIST(),
219
- ret = get_phys_addr_lpae(env, ptw, ipa, access_type, is_el0, result, fi);
99
};
220
+ if (arm_feature(env, ARM_FEATURE_PMSA)) {
100
221
+ ret = get_phys_addr_pmsav8(env, ipa, access_type,
101
@@ -XXX,XX +XXX,XX @@ static void xilinx_intc_class_init(ObjectClass *klass, void *data)
222
+ ptw->in_mmu_idx, is_secure, result, fi);
102
static const TypeInfo xilinx_intc_info = {
223
+ } else {
103
.name = TYPE_XILINX_INTC,
224
+ ret = get_phys_addr_lpae(env, ptw, ipa, access_type,
104
.parent = TYPE_SYS_BUS_DEVICE,
225
+ is_el0, result, fi);
105
- .instance_size = sizeof(struct xlx_pic),
226
+ }
106
+ .instance_size = sizeof(XpsIntc),
227
fi->s2addr = ipa;
107
.instance_init = xilinx_intc_init,
228
108
.class_init = xilinx_intc_class_init,
229
/* Combine the S1 and S2 perms. */
109
};
230
--
110
--
231
2.25.1
111
2.34.1
232
112
233
113
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Silent when compiling with -Wextra:
3
This remove a use of 'struct' in the DECLARE_INSTANCE_CHECKER()
4
macro call, to avoid after a QOM refactor:
4
5
5
../hw/arm/nseries.c:1081:12: warning: missing field 'line' initializer [-Wmissing-field-initializers]
6
hw/timer/xilinx_timer.c:65:1: error: declaration of anonymous struct must be a definition
6
{ NULL }
7
DECLARE_INSTANCE_CHECKER(struct timerblock, XILINX_TIMER,
7
^
8
^
8
9
9
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
Message-id: 20221220142520.24094-4-philmd@linaro.org
11
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
12
Reviewed-by: Edgar E. Iglesias <edgar@zeroasic.com>
13
Message-id: 20230109140306.23161-15-philmd@linaro.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
15
---
14
hw/arm/nseries.c | 10 ++++------
16
hw/timer/xilinx_timer.c | 27 +++++++++++++--------------
15
1 file changed, 4 insertions(+), 6 deletions(-)
17
1 file changed, 13 insertions(+), 14 deletions(-)
16
18
17
diff --git a/hw/arm/nseries.c b/hw/arm/nseries.c
19
diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c
18
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
19
--- a/hw/arm/nseries.c
21
--- a/hw/timer/xilinx_timer.c
20
+++ b/hw/arm/nseries.c
22
+++ b/hw/timer/xilinx_timer.c
21
@@ -XXX,XX +XXX,XX @@ static const struct omap_gpiosw_info_s {
23
@@ -XXX,XX +XXX,XX @@ struct xlx_timer
22
"headphone", N8X0_HEADPHONE_GPIO,
23
OMAP_GPIOSW_TYPE_CONNECTION | OMAP_GPIOSW_INVERTED,
24
},
25
- { NULL }
26
+ { /* end of list */ }
27
}, n810_gpiosw_info[] = {
28
{
29
"gps_reset", N810_GPS_RESET_GPIO,
30
@@ -XXX,XX +XXX,XX @@ static const struct omap_gpiosw_info_s {
31
"slide", N810_SLIDE_GPIO,
32
OMAP_GPIOSW_TYPE_COVER | OMAP_GPIOSW_INVERTED,
33
},
34
- { NULL }
35
+ { /* end of list */ }
36
};
24
};
37
25
38
static const struct omap_partition_info_s {
26
#define TYPE_XILINX_TIMER "xlnx.xps-timer"
39
@@ -XXX,XX +XXX,XX @@ static const struct omap_partition_info_s {
27
-DECLARE_INSTANCE_CHECKER(struct timerblock, XILINX_TIMER,
40
{ 0x00080000, 0x00200000, 0x0, "kernel" },
28
- TYPE_XILINX_TIMER)
41
{ 0x00280000, 0x00200000, 0x3, "initfs" },
29
+typedef struct XpsTimerState XpsTimerState;
42
{ 0x00480000, 0x0fb80000, 0x3, "rootfs" },
30
+DECLARE_INSTANCE_CHECKER(XpsTimerState, XILINX_TIMER, TYPE_XILINX_TIMER)
43
-
31
44
- { 0, 0, 0, NULL }
32
-struct timerblock
45
+ { /* end of list */ }
33
+struct XpsTimerState
46
}, n810_part_info[] = {
34
{
47
{ 0x00000000, 0x00020000, 0x3, "bootloader" },
35
SysBusDevice parent_obj;
48
{ 0x00020000, 0x00060000, 0x0, "config" },
36
49
{ 0x00080000, 0x00220000, 0x0, "kernel" },
37
@@ -XXX,XX +XXX,XX @@ struct timerblock
50
{ 0x002a0000, 0x00400000, 0x0, "initfs" },
38
struct xlx_timer *timers;
51
{ 0x006a0000, 0x0f960000, 0x0, "rootfs" },
52
-
53
- { 0, 0, 0, NULL }
54
+ { /* end of list */ }
55
};
39
};
56
40
57
static const uint8_t n8x0_bd_addr[6] = { N8X0_BD_ADDR };
41
-static inline unsigned int num_timers(struct timerblock *t)
42
+static inline unsigned int num_timers(XpsTimerState *t)
43
{
44
return 2 - t->one_timer_only;
45
}
46
@@ -XXX,XX +XXX,XX @@ static inline unsigned int timer_from_addr(hwaddr addr)
47
return addr >> 2;
48
}
49
50
-static void timer_update_irq(struct timerblock *t)
51
+static void timer_update_irq(XpsTimerState *t)
52
{
53
unsigned int i, irq = 0;
54
uint32_t csr;
55
@@ -XXX,XX +XXX,XX @@ static void timer_update_irq(struct timerblock *t)
56
static uint64_t
57
timer_read(void *opaque, hwaddr addr, unsigned int size)
58
{
59
- struct timerblock *t = opaque;
60
+ XpsTimerState *t = opaque;
61
struct xlx_timer *xt;
62
uint32_t r = 0;
63
unsigned int timer;
64
@@ -XXX,XX +XXX,XX @@ static void
65
timer_write(void *opaque, hwaddr addr,
66
uint64_t val64, unsigned int size)
67
{
68
- struct timerblock *t = opaque;
69
+ XpsTimerState *t = opaque;
70
struct xlx_timer *xt;
71
unsigned int timer;
72
uint32_t value = val64;
73
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps timer_ops = {
74
static void timer_hit(void *opaque)
75
{
76
struct xlx_timer *xt = opaque;
77
- struct timerblock *t = xt->parent;
78
+ XpsTimerState *t = xt->parent;
79
D(fprintf(stderr, "%s %d\n", __func__, xt->nr));
80
xt->regs[R_TCSR] |= TCSR_TINT;
81
82
@@ -XXX,XX +XXX,XX @@ static void timer_hit(void *opaque)
83
84
static void xilinx_timer_realize(DeviceState *dev, Error **errp)
85
{
86
- struct timerblock *t = XILINX_TIMER(dev);
87
+ XpsTimerState *t = XILINX_TIMER(dev);
88
unsigned int i;
89
90
/* Init all the ptimers. */
91
@@ -XXX,XX +XXX,XX @@ static void xilinx_timer_realize(DeviceState *dev, Error **errp)
92
93
static void xilinx_timer_init(Object *obj)
94
{
95
- struct timerblock *t = XILINX_TIMER(obj);
96
+ XpsTimerState *t = XILINX_TIMER(obj);
97
98
/* All timers share a single irq line. */
99
sysbus_init_irq(SYS_BUS_DEVICE(obj), &t->irq);
100
}
101
102
static Property xilinx_timer_properties[] = {
103
- DEFINE_PROP_UINT32("clock-frequency", struct timerblock, freq_hz,
104
- 62 * 1000000),
105
- DEFINE_PROP_UINT8("one-timer-only", struct timerblock, one_timer_only, 0),
106
+ DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 1000000),
107
+ DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0),
108
DEFINE_PROP_END_OF_LIST(),
109
};
110
111
@@ -XXX,XX +XXX,XX @@ static void xilinx_timer_class_init(ObjectClass *klass, void *data)
112
static const TypeInfo xilinx_timer_info = {
113
.name = TYPE_XILINX_TIMER,
114
.parent = TYPE_SYS_BUS_DEVICE,
115
- .instance_size = sizeof(struct timerblock),
116
+ .instance_size = sizeof(XpsTimerState),
117
.instance_init = xilinx_timer_init,
118
.class_init = xilinx_timer_class_init,
119
};
58
--
120
--
59
2.25.1
121
2.34.1
60
122
61
123
diff view generated by jsdifflib
1
From: Fabiano Rosas <farosas@suse.de>
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
2
3
Fix this:
3
ARM trusted firmware, when built with FEAT_HCX support, sets SCR_EL3.HXEn bit
4
ERROR: braces {} are necessary for all arms of this statement
4
to allow EL2 to modify HCRX_EL2 register without trapping it in EL3. Qemu
5
uses a valid mask to clear unsupported SCR_EL3 bits when emulating SCR_EL3
6
write, and that mask doesn't include SCR_EL3.HXEn bit even if FEAT_HCX is
7
enabled and exposed to the guest. As a result EL3 writes of that bit are
8
ignored.
5
9
6
Signed-off-by: Fabiano Rosas <farosas@suse.de>
10
Cc: qemu-stable@nongnu.org
7
Reviewed-by: Claudio Fontana <cfontana@suse.de>
11
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
8
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
12
Message-id: 20230105221251.17896-4-eiakovlev@linux.microsoft.com
9
Message-id: 20221213190537.511-4-farosas@suse.de
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
---
15
---
12
target/arm/helper.c | 67 ++++++++++++++++++++++++++++-----------------
16
target/arm/helper.c | 3 +++
13
1 file changed, 42 insertions(+), 25 deletions(-)
17
1 file changed, 3 insertions(+)
14
18
15
diff --git a/target/arm/helper.c b/target/arm/helper.c
19
diff --git a/target/arm/helper.c b/target/arm/helper.c
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/helper.c
21
--- a/target/arm/helper.c
18
+++ b/target/arm/helper.c
22
+++ b/target/arm/helper.c
19
@@ -XXX,XX +XXX,XX @@ void cpsr_write(CPUARMState *env, uint32_t val, uint32_t mask,
23
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
20
env->CF = (val >> 29) & 1;
24
if (cpu_isar_feature(aa64_sme, cpu)) {
21
env->VF = (val << 3) & 0x80000000;
25
valid_mask |= SCR_ENTP2;
22
}
26
}
23
- if (mask & CPSR_Q)
27
+ if (cpu_isar_feature(aa64_hcx, cpu)) {
24
+ if (mask & CPSR_Q) {
28
+ valid_mask |= SCR_HXEN;
25
env->QF = ((val & CPSR_Q) != 0);
26
- if (mask & CPSR_T)
27
+ }
28
+ if (mask & CPSR_T) {
29
env->thumb = ((val & CPSR_T) != 0);
30
+ }
31
if (mask & CPSR_IT_0_1) {
32
env->condexec_bits &= ~3;
33
env->condexec_bits |= (val >> 25) & 3;
34
@@ -XXX,XX +XXX,XX @@ static void switch_mode(CPUARMState *env, int mode)
35
int i;
36
37
old_mode = env->uncached_cpsr & CPSR_M;
38
- if (mode == old_mode)
39
+ if (mode == old_mode) {
40
return;
41
+ }
42
43
if (old_mode == ARM_CPU_MODE_FIQ) {
44
memcpy(env->fiq_regs, env->regs + 8, 5 * sizeof(uint32_t));
45
@@ -XXX,XX +XXX,XX @@ static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
46
new_mode = ARM_CPU_MODE_UND;
47
addr = 0x04;
48
mask = CPSR_I;
49
- if (env->thumb)
50
+ if (env->thumb) {
51
offset = 2;
52
- else
53
+ } else {
54
offset = 4;
55
+ }
29
+ }
56
break;
30
} else {
57
case EXCP_SWI:
31
valid_mask &= ~(SCR_RW | SCR_ST);
58
new_mode = ARM_CPU_MODE_SVC;
32
if (cpu_isar_feature(aa32_ras, cpu)) {
59
@@ -XXX,XX +XXX,XX @@ static inline uint16_t add16_sat(uint16_t a, uint16_t b)
60
61
res = a + b;
62
if (((res ^ a) & 0x8000) && !((a ^ b) & 0x8000)) {
63
- if (a & 0x8000)
64
+ if (a & 0x8000) {
65
res = 0x8000;
66
- else
67
+ } else {
68
res = 0x7fff;
69
+ }
70
}
71
return res;
72
}
73
@@ -XXX,XX +XXX,XX @@ static inline uint8_t add8_sat(uint8_t a, uint8_t b)
74
75
res = a + b;
76
if (((res ^ a) & 0x80) && !((a ^ b) & 0x80)) {
77
- if (a & 0x80)
78
+ if (a & 0x80) {
79
res = 0x80;
80
- else
81
+ } else {
82
res = 0x7f;
83
+ }
84
}
85
return res;
86
}
87
@@ -XXX,XX +XXX,XX @@ static inline uint16_t sub16_sat(uint16_t a, uint16_t b)
88
89
res = a - b;
90
if (((res ^ a) & 0x8000) && ((a ^ b) & 0x8000)) {
91
- if (a & 0x8000)
92
+ if (a & 0x8000) {
93
res = 0x8000;
94
- else
95
+ } else {
96
res = 0x7fff;
97
+ }
98
}
99
return res;
100
}
101
@@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_sat(uint8_t a, uint8_t b)
102
103
res = a - b;
104
if (((res ^ a) & 0x80) && ((a ^ b) & 0x80)) {
105
- if (a & 0x80)
106
+ if (a & 0x80) {
107
res = 0x80;
108
- else
109
+ } else {
110
res = 0x7f;
111
+ }
112
}
113
return res;
114
}
115
@@ -XXX,XX +XXX,XX @@ static inline uint16_t add16_usat(uint16_t a, uint16_t b)
116
{
117
uint16_t res;
118
res = a + b;
119
- if (res < a)
120
+ if (res < a) {
121
res = 0xffff;
122
+ }
123
return res;
124
}
125
126
static inline uint16_t sub16_usat(uint16_t a, uint16_t b)
127
{
128
- if (a > b)
129
+ if (a > b) {
130
return a - b;
131
- else
132
+ } else {
133
return 0;
134
+ }
135
}
136
137
static inline uint8_t add8_usat(uint8_t a, uint8_t b)
138
{
139
uint8_t res;
140
res = a + b;
141
- if (res < a)
142
+ if (res < a) {
143
res = 0xff;
144
+ }
145
return res;
146
}
147
148
static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
149
{
150
- if (a > b)
151
+ if (a > b) {
152
return a - b;
153
- else
154
+ } else {
155
return 0;
156
+ }
157
}
158
159
#define ADD16(a, b, n) RESULT(add16_usat(a, b), n, 16);
160
@@ -XXX,XX +XXX,XX @@ static inline uint8_t sub8_usat(uint8_t a, uint8_t b)
161
162
static inline uint8_t do_usad(uint8_t a, uint8_t b)
163
{
164
- if (a > b)
165
+ if (a > b) {
166
return a - b;
167
- else
168
+ } else {
169
return b - a;
170
+ }
171
}
172
173
/* Unsigned sum of absolute byte differences. */
174
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sel_flags)(uint32_t flags, uint32_t a, uint32_t b)
175
uint32_t mask;
176
177
mask = 0;
178
- if (flags & 1)
179
+ if (flags & 1) {
180
mask |= 0xff;
181
- if (flags & 2)
182
+ }
183
+ if (flags & 2) {
184
mask |= 0xff00;
185
- if (flags & 4)
186
+ }
187
+ if (flags & 4) {
188
mask |= 0xff0000;
189
- if (flags & 8)
190
+ }
191
+ if (flags & 8) {
192
mask |= 0xff000000;
193
+ }
194
return (a & mask) | (b & ~mask);
195
}
196
197
--
33
--
198
2.25.1
34
2.34.1
diff view generated by jsdifflib