1
Last pullreq before 6.0 softfreeze: a few minor feature patches,
1
The following changes since commit 3db29dcac23da85486704ef9e7a8e7217f7829cd:
2
some bugfixes, some cleanups.
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 6f34661b6c97a37a5efc27d31c037ddeda4547e2:
7
8
Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for-6.0-pull-request' into staging (2021-03-11 18:55:27 +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-20210312-1
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 41f09f2e9f09e4dd386d84174a6dcb5136af17ca:
9
for you to fetch changes up to 08899b5c68a55a3780d707e2464073c8f2670d31:
15
10
16
hw/display/pxa2xx: Inline template header (2021-03-12 13:26:08 +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
* versal: Support XRAMs and XRAM controller
15
hw/arm/stm32f405: correctly describe the memory layout
21
* smmu: Various minor bug fixes
16
hw/arm: Add Olimex H405 board
22
* SVE emulation: fix bugs handling odd vector lengths
17
cubieboard: Support booting from an SD card image with u-boot on it
23
* allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value
18
target/arm: Fix sve_probe_page
24
* tests/acceptance: fix orangepi-pc acceptance tests
19
target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
25
* hw/timer/sse-timer: Propagate eventual error in sse_timer_realize()
20
various code cleanups
26
* hw/arm/virt: KVM: The IPA lower bound is 32
27
* npcm7xx: support MFT module
28
* pl110, pxa2xx_lcd: tidy up template headers
29
21
30
----------------------------------------------------------------
22
----------------------------------------------------------------
31
Andrew Jones (2):
23
Evgeny Iakovlev (1):
32
accel: kvm: Fix kvm_type invocation
24
target/arm: allow writes to SCR_EL3.HXEn bit when FEAT_HCX is enabled
33
hw/arm/virt: KVM: The IPA lower bound is 32
34
25
35
Edgar E. Iglesias (2):
26
Felipe Balbi (2):
36
hw/misc: versal: Add a model of the XRAM controller
27
hw/arm/stm32f405: correctly describe the memory layout
37
hw/arm: versal: Add support for the XRAMs
28
hw/arm: Add Olimex H405
38
29
39
Eric Auger (7):
30
Philippe Mathieu-Daudé (27):
40
intel_iommu: Fix mask may be uninitialized in vtd_context_device_invalidate
31
hw/arm/pxa2xx: Simplify pxa255_init()
41
dma: Introduce dma_aligned_pow2_mask()
32
hw/arm/pxa2xx: Simplify pxa270_init()
42
virtio-iommu: Handle non power of 2 range invalidations
33
hw/arm/collie: Use the IEC binary prefix definitions
43
hw/arm/smmu-common: Fix smmu_iotlb_inv_iova when asid is not set
34
hw/arm/collie: Simplify flash creation using for() loop
44
hw/arm/smmuv3: Enforce invalidation on a power of two range
35
hw/arm/gumstix: Improve documentation
45
hw/arm/smmuv3: Fix SMMU_CMD_CFGI_STE_RANGE handling
36
hw/arm/gumstix: Use the IEC binary prefix definitions
46
hw/arm/smmuv3: Uniformize sid traces
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'
47
58
48
Hao Wu (5):
59
Richard Henderson (1):
49
hw/misc: Add GPIOs for duty in NPCM7xx PWM
60
target/arm: Fix sve_probe_page
50
hw/misc: Add NPCM7XX MFT Module
51
hw/arm: Add MFT device to NPCM7xx Soc
52
hw/arm: Connect PWM fans in NPCM7XX boards
53
tests/qtest: Test PWM fan RPM using MFT in PWM test
54
61
55
Niek Linnenbank (5):
62
Strahinja Jankovic (7):
56
hw/net/allwinner-sun8i-emac: traverse transmit queue using TX_CUR_DESC register value
63
hw/misc: Allwinner-A10 Clock Controller Module Emulation
57
tests/acceptance/boot_linux_console: remove Armbian 19.11.3 bionic test for orangepi-pc machine
64
hw/misc: Allwinner A10 DRAM Controller Emulation
58
tests/acceptance/boot_linux_console: change URL for test_arm_orangepi_bionic_20_08
65
{hw/i2c,docs/system/arm}: Allwinner TWI/I2C Emulation
59
tests/acceptance: update sunxi kernel from armbian to 5.10.16
66
hw/misc: AXP209 PMU Emulation
60
tests/acceptance: drop ARMBIAN_ARTIFACTS_CACHED condition for orangepi-pc, cubieboard tests
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
61
70
62
Peter Maydell (9):
71
docs/system/arm/cubieboard.rst | 1 +
63
hw/display/pl110: Remove dead code for non-32-bpp surfaces
72
docs/system/arm/orangepi.rst | 1 +
64
hw/display/pl110: Pull included-once parts of template header into pl110.c
73
docs/system/arm/stm32.rst | 1 +
65
hw/display/pl110: Remove use of BITS from pl110_template.h
74
configs/devices/arm-softmmu/default.mak | 1 +
66
hw/display/pxa2xx_lcd: Remove dead code for non-32-bpp surfaces
75
include/hw/adc/npcm7xx_adc.h | 7 +-
67
hw/display/pxa2xx_lcd: Remove dest_width state field
76
include/hw/arm/allwinner-a10.h | 27 ++
68
hw/display/pxa2xx: Remove use of BITS in pxa2xx_template.h
77
include/hw/arm/allwinner-h3.h | 3 +
69
hw/display/pxa2xx: Apply brace-related coding style fixes to template header
78
include/hw/arm/npcm7xx.h | 18 +-
70
hw/display/pxa2xx: Apply whitespace-only coding style fixes to template header
79
include/hw/arm/omap.h | 24 +-
71
hw/display/pxa2xx: Inline template header
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
72
156
73
Philippe Mathieu-Daudé (1):
74
hw/timer/sse-timer: Propagate eventual error in sse_timer_realize()
75
76
Richard Henderson (8):
77
target/arm: Fix sve_uzp_p vs odd vector lengths
78
target/arm: Fix sve_zip_p vs odd vector lengths
79
target/arm: Fix sve_punpk_p vs odd vector lengths
80
target/arm: Update find_last_active for PREDDESC
81
target/arm: Update BRKA, BRKB, BRKN for PREDDESC
82
target/arm: Update CNTP for PREDDESC
83
target/arm: Update WHILE for PREDDESC
84
target/arm: Update sve reduction vs simd_desc
85
86
docs/system/arm/nuvoton.rst | 2 +-
87
docs/system/arm/xlnx-versal-virt.rst | 1 +
88
hw/arm/smmu-internal.h | 5 +
89
hw/display/pl110_template.h | 120 +-------
90
hw/display/pxa2xx_template.h | 447 ---------------------------
91
include/hw/arm/npcm7xx.h | 13 +-
92
include/hw/arm/xlnx-versal.h | 13 +
93
include/hw/boards.h | 1 +
94
include/hw/misc/npcm7xx_mft.h | 70 +++++
95
include/hw/misc/npcm7xx_pwm.h | 4 +-
96
include/hw/misc/xlnx-versal-xramc.h | 97 ++++++
97
include/sysemu/dma.h | 12 +
98
target/arm/kvm_arm.h | 6 +-
99
accel/kvm/kvm-all.c | 2 +
100
hw/arm/npcm7xx.c | 45 ++-
101
hw/arm/npcm7xx_boards.c | 99 ++++++
102
hw/arm/smmu-common.c | 32 +-
103
hw/arm/smmuv3.c | 58 ++--
104
hw/arm/virt.c | 23 +-
105
hw/arm/xlnx-versal.c | 36 +++
106
hw/display/pl110.c | 123 +++++---
107
hw/display/pxa2xx_lcd.c | 520 ++++++++++++++++++++++++++-----
108
hw/i386/intel_iommu.c | 32 +-
109
hw/misc/npcm7xx_mft.c | 540 +++++++++++++++++++++++++++++++++
110
hw/misc/npcm7xx_pwm.c | 4 +
111
hw/misc/xlnx-versal-xramc.c | 253 +++++++++++++++
112
hw/net/allwinner-sun8i-emac.c | 62 ++--
113
hw/timer/sse-timer.c | 1 +
114
hw/virtio/virtio-iommu.c | 19 +-
115
softmmu/dma-helpers.c | 26 ++
116
target/arm/kvm.c | 4 +-
117
target/arm/sve_helper.c | 107 ++++---
118
target/arm/translate-sve.c | 26 +-
119
tests/qtest/npcm7xx_pwm-test.c | 205 ++++++++++++-
120
hw/arm/trace-events | 24 +-
121
hw/misc/meson.build | 2 +
122
hw/misc/trace-events | 8 +
123
tests/acceptance/boot_linux_console.py | 120 +++-----
124
tests/acceptance/replay_kernel.py | 10 +-
125
39 files changed, 2235 insertions(+), 937 deletions(-)
126
delete mode 100644 hw/display/pxa2xx_template.h
127
create mode 100644 include/hw/misc/npcm7xx_mft.h
128
create mode 100644 include/hw/misc/xlnx-versal-xramc.h
129
create mode 100644 hw/misc/npcm7xx_mft.c
130
create mode 100644 hw/misc/xlnx-versal-xramc.c
131
diff view generated by jsdifflib
1
From: Niek Linnenbank <nieklinnenbank@gmail.com>
1
From: Felipe Balbi <balbi@kernel.org>
2
2
3
Previously the ARMBIAN_ARTIFACTS_CACHED pre-condition was added to allow running
3
STM32F405 has 128K of SRAM and another 64K of CCM (Core-coupled
4
tests that have already existing armbian.com artifacts stored in the local avocado cache,
4
Memory) at a different base address. Correctly describe the memory
5
but do not have working URLs to download a fresh copy.
5
layout to give existing FW images a chance to run unmodified.
6
6
7
At this time of writing the URLs for artifacts on the armbian.com server are updated and working.
7
Reviewed-by: Alistair Francis <alistair@alistair23.me>
8
Any future broken URLs will result in a skipped acceptance test, for example:
8
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
9
Signed-off-by: Felipe Balbi <balbi@kernel.org>
10
(1/5) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi:
10
Message-id: 20221230145733.200496-2-balbi@kernel.org
11
CANCEL: Missing asset https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb (0.53 s)
12
13
This commits removes the ARMBIAN_ARTIFACTS_CACHED pre-condition such that
14
the acceptance tests for the orangepi-pc and cubieboard machines can run.
15
16
Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
17
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
18
Message-id: 20210310195820.21950-6-nieklinnenbank@gmail.com
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
12
---
21
tests/acceptance/boot_linux_console.py | 12 ------------
13
include/hw/arm/stm32f405_soc.h | 5 ++++-
22
tests/acceptance/replay_kernel.py | 2 --
14
hw/arm/stm32f405_soc.c | 8 ++++++++
23
2 files changed, 14 deletions(-)
15
2 files changed, 12 insertions(+), 1 deletion(-)
24
16
25
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
17
diff --git a/include/hw/arm/stm32f405_soc.h b/include/hw/arm/stm32f405_soc.h
26
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
27
--- a/tests/acceptance/boot_linux_console.py
19
--- a/include/hw/arm/stm32f405_soc.h
28
+++ b/tests/acceptance/boot_linux_console.py
20
+++ b/include/hw/arm/stm32f405_soc.h
29
@@ -XXX,XX +XXX,XX @@ def test_arm_exynos4210_initrd(self):
21
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(STM32F405State, STM32F405_SOC)
30
self.wait_for_console_pattern('Boot successful.')
22
#define FLASH_BASE_ADDRESS 0x08000000
31
# TODO user command, for now the uart is stuck
23
#define FLASH_SIZE (1024 * 1024)
32
24
#define SRAM_BASE_ADDRESS 0x20000000
33
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
25
-#define SRAM_SIZE (192 * 1024)
34
- 'Test artifacts fetched from unreliable apt.armbian.com')
26
+#define SRAM_SIZE (128 * 1024)
35
def test_arm_cubieboard_initrd(self):
27
+#define CCM_BASE_ADDRESS 0x10000000
36
"""
28
+#define CCM_SIZE (64 * 1024)
37
:avocado: tags=arch:arm
29
38
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self):
30
struct STM32F405State {
39
'system-control@1c00000')
31
/*< private >*/
40
# cubieboard's reboot is not functioning; omit reboot test.
32
@@ -XXX,XX +XXX,XX @@ struct STM32F405State {
41
33
STM32F2XXADCState adc[STM_NUM_ADCS];
42
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
34
STM32F2XXSPIState spi[STM_NUM_SPIS];
43
- 'Test artifacts fetched from unreliable apt.armbian.com')
35
44
def test_arm_cubieboard_sata(self):
36
+ MemoryRegion ccm;
45
"""
37
MemoryRegion sram;
46
:avocado: tags=arch:arm
38
MemoryRegion flash;
47
@@ -XXX,XX +XXX,XX @@ def test_arm_quanta_gsj_initrd(self):
39
MemoryRegion flash_alias;
48
self.wait_for_console_pattern(
40
diff --git a/hw/arm/stm32f405_soc.c b/hw/arm/stm32f405_soc.c
49
'Give root password for system maintenance')
50
51
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
52
- 'Test artifacts fetched from unreliable apt.armbian.com')
53
def test_arm_orangepi(self):
54
"""
55
:avocado: tags=arch:arm
56
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi(self):
57
console_pattern = 'Kernel command line: %s' % kernel_command_line
58
self.wait_for_console_pattern(console_pattern)
59
60
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
61
- 'Test artifacts fetched from unreliable apt.armbian.com')
62
def test_arm_orangepi_initrd(self):
63
"""
64
:avocado: tags=arch:arm
65
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_initrd(self):
66
# Wait for VM to shut down gracefully
67
self.vm.wait()
68
69
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
70
- 'Test artifacts fetched from unreliable apt.armbian.com')
71
def test_arm_orangepi_sd(self):
72
"""
73
:avocado: tags=arch:arm
74
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self):
75
# Wait for VM to shut down gracefully
76
self.vm.wait()
77
78
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
79
- 'Test artifacts fetched from unreliable apt.armbian.com')
80
@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
81
def test_arm_orangepi_bionic_20_08(self):
82
"""
83
diff --git a/tests/acceptance/replay_kernel.py b/tests/acceptance/replay_kernel.py
84
index XXXXXXX..XXXXXXX 100644
41
index XXXXXXX..XXXXXXX 100644
85
--- a/tests/acceptance/replay_kernel.py
42
--- a/hw/arm/stm32f405_soc.c
86
+++ b/tests/acceptance/replay_kernel.py
43
+++ b/hw/arm/stm32f405_soc.c
87
@@ -XXX,XX +XXX,XX @@ def test_arm_virt(self):
44
@@ -XXX,XX +XXX,XX @@ static void stm32f405_soc_realize(DeviceState *dev_soc, Error **errp)
88
self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=1)
45
}
89
46
memory_region_add_subregion(system_memory, SRAM_BASE_ADDRESS, &s->sram);
90
@skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab')
47
91
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
48
+ memory_region_init_ram(&s->ccm, NULL, "STM32F405.ccm", CCM_SIZE,
92
- 'Test artifacts fetched from unreliable apt.armbian.com')
49
+ &err);
93
def test_arm_cubieboard_initrd(self):
50
+ if (err != NULL) {
94
"""
51
+ error_propagate(errp, err);
95
:avocado: tags=arch:arm
52
+ return;
53
+ }
54
+ memory_region_add_subregion(system_memory, CCM_BASE_ADDRESS, &s->ccm);
55
+
56
armv7m = DEVICE(&s->armv7m);
57
qdev_prop_set_uint32(armv7m, "num-irq", 96);
58
qdev_prop_set_string(armv7m, "cpu-type", s->cpu_type);
96
--
59
--
97
2.20.1
60
2.34.1
98
61
99
62
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Felipe Balbi <balbi@kernel.org>
2
2
3
This patch adds testing of PWM fan RPMs in the existing npcm7xx pwm
3
Olimex makes a series of low-cost STM32 boards. This commit introduces
4
test. It tests whether the MFT module can measure correct fan values
4
the minimum setup to support SMT32-H405. See [1] for details
5
for a PWM fan in NPCM7XX boards.
6
5
7
Reviewed-by: Doug Evans <dje@google.com>
6
[1] https://www.olimex.com/Products/ARM/ST/STM32-H405/
8
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
7
9
Signed-off-by: Hao Wu <wuhaotsh@google.com>
8
Signed-off-by: Felipe Balbi <balbi@kernel.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
11
Message-id: 20210311180855.149764-6-wuhaotsh@google.com
10
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
11
Message-id: 20221230145733.200496-3-balbi@kernel.org
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
13
---
14
tests/qtest/npcm7xx_pwm-test.c | 205 ++++++++++++++++++++++++++++++++-
14
docs/system/arm/stm32.rst | 1 +
15
1 file changed, 199 insertions(+), 6 deletions(-)
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
16
22
17
diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c
23
diff --git a/docs/system/arm/stm32.rst b/docs/system/arm/stm32.rst
18
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/qtest/npcm7xx_pwm-test.c
25
--- a/docs/system/arm/stm32.rst
20
+++ b/tests/qtest/npcm7xx_pwm-test.c
26
+++ b/docs/system/arm/stm32.rst
27
@@ -XXX,XX +XXX,XX @@ The STM32F4 series is based on ARM Cortex-M4F core. This series is pin-to-pin
28
compatible with STM32F2 series. The following machines are based on this chip :
29
30
- ``netduinoplus2`` Netduino Plus 2 board with STM32F405RGT6 microcontroller
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
21
@@ -XXX,XX +XXX,XX @@
52
@@ -XXX,XX +XXX,XX @@
22
#define PLL_FBDV(rv) extract32((rv), 16, 12)
53
+/*
23
#define PLL_OTDV1(rv) extract32((rv), 8, 3)
54
+ * ST STM32VLDISCOVERY machine
24
#define PLL_OTDV2(rv) extract32((rv), 13, 3)
55
+ * Olimex STM32-H405 machine
25
+#define APB4CKDIV(rv) extract32((rv), 30, 2)
56
+ *
26
#define APB3CKDIV(rv) extract32((rv), 28, 2)
57
+ * Copyright (c) 2022 Felipe Balbi <balbi@kernel.org>
27
#define CLK2CKDIV(rv) extract32((rv), 0, 1)
58
+ *
28
#define CLK4CKDIV(rv) extract32((rv), 26, 2)
59
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
29
@@ -XXX,XX +XXX,XX @@
60
+ * of this software and associated documentation files (the "Software"), to deal
30
61
+ * in the Software without restriction, including without limitation the rights
31
#define MAX_DUTY 1000000
62
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32
63
+ * copies of the Software, and to permit persons to whom the Software is
33
+/* MFT (PWM fan) related */
64
+ * furnished to do so, subject to the following conditions:
34
+#define MFT_BA(n) (0xf0180000 + ((n) * 0x1000))
65
+ *
35
+#define MFT_IRQ(n) (96 + (n))
66
+ * The above copyright notice and this permission notice shall be included in
36
+#define MFT_CNT1 0x00
67
+ * all copies or substantial portions of the Software.
37
+#define MFT_CRA 0x02
68
+ *
38
+#define MFT_CRB 0x04
69
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39
+#define MFT_CNT2 0x06
70
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40
+#define MFT_PRSC 0x08
71
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
41
+#define MFT_CKC 0x0a
72
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42
+#define MFT_MCTRL 0x0c
73
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
+#define MFT_ICTRL 0x0e
74
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
44
+#define MFT_ICLR 0x10
75
+ * THE SOFTWARE.
45
+#define MFT_IEN 0x12
76
+ */
46
+#define MFT_CPA 0x14
47
+#define MFT_CPB 0x16
48
+#define MFT_CPCFG 0x18
49
+#define MFT_INASEL 0x1a
50
+#define MFT_INBSEL 0x1c
51
+
77
+
52
+#define MFT_MCTRL_ALL 0x64
78
+#include "qemu/osdep.h"
53
+#define MFT_ICLR_ALL 0x3f
79
+#include "qapi/error.h"
54
+#define MFT_IEN_ALL 0x3f
80
+#include "hw/boards.h"
55
+#define MFT_CPCFG_EQ_MODE 0x44
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"
56
+
86
+
57
+#define MFT_CKC_C2CSEL BIT(3)
87
+/* olimex-stm32-h405 implementation is derived from netduinoplus2 */
58
+#define MFT_CKC_C1CSEL BIT(0)
59
+
88
+
60
+#define MFT_ICTRL_TFPND BIT(5)
89
+/* Main SYSCLK frequency in Hz (168MHz) */
61
+#define MFT_ICTRL_TEPND BIT(4)
90
+#define SYSCLK_FRQ 168000000ULL
62
+#define MFT_ICTRL_TDPND BIT(3)
63
+#define MFT_ICTRL_TCPND BIT(2)
64
+#define MFT_ICTRL_TBPND BIT(1)
65
+#define MFT_ICTRL_TAPND BIT(0)
66
+
91
+
67
+#define MFT_MAX_CNT 0xffff
92
+static void olimex_stm32_h405_init(MachineState *machine)
68
+#define MFT_TIMEOUT 0x5000
93
+{
94
+ DeviceState *dev;
95
+ Clock *sysclk;
69
+
96
+
70
+#define DEFAULT_RPM 19800
97
+ /* This clock doesn't need migration because it is fixed-frequency */
71
+#define DEFAULT_PRSC 255
98
+ sysclk = clock_new(OBJECT(machine), "SYSCLK");
72
+#define MFT_PULSE_PER_REVOLUTION 2
99
+ clock_set_hz(sysclk, SYSCLK_FRQ);
73
+
100
+
74
+#define MAX_ERROR 1
101
+ dev = qdev_new(TYPE_STM32F405_SOC);
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);
75
+
105
+
76
typedef struct PWMModule {
106
+ armv7m_load_kernel(ARM_CPU(first_cpu),
77
int irq;
107
+ machine->kernel_filename,
78
uint64_t base_addr;
108
+ 0, FLASH_SIZE);
79
@@ -XXX,XX +XXX,XX @@ static uint64_t pwm_get_duty(QTestState *qts, int module_index, int pwm_index)
80
return pwm_qom_get(qts, path, name);
81
}
82
83
+static void mft_qom_set(QTestState *qts, int index, const char *name,
84
+ uint32_t value)
85
+{
86
+ QDict *response;
87
+ char *path = g_strdup_printf("/machine/soc/mft[%d]", index);
88
+
89
+ g_test_message("Setting properties %s of mft[%d] with value %u",
90
+ name, index, value);
91
+ response = qtest_qmp(qts, "{ 'execute': 'qom-set',"
92
+ " 'arguments': { 'path': %s, "
93
+ " 'property': %s, 'value': %u}}",
94
+ path, name, value);
95
+ /* The qom set message returns successfully. */
96
+ g_assert_true(qdict_haskey(response, "return"));
97
+}
109
+}
98
+
110
+
99
static uint32_t get_pll(uint32_t con)
111
+static void olimex_stm32_h405_machine_init(MachineClass *mc)
100
{
101
return REF_HZ * PLL_FBDV(con) / (PLL_INDV(con) * PLL_OTDV1(con)
102
* PLL_OTDV2(con));
103
}
104
105
-static uint64_t read_pclk(QTestState *qts)
106
+static uint64_t read_pclk(QTestState *qts, bool mft)
107
{
108
uint64_t freq = REF_HZ;
109
uint32_t clksel = qtest_readl(qts, CLK_BA + CLKSEL);
110
uint32_t pllcon;
111
uint32_t clkdiv1 = qtest_readl(qts, CLK_BA + CLKDIV1);
112
uint32_t clkdiv2 = qtest_readl(qts, CLK_BA + CLKDIV2);
113
+ uint32_t apbdiv = mft ? APB4CKDIV(clkdiv2) : APB3CKDIV(clkdiv2);
114
115
switch (CPUCKSEL(clksel)) {
116
case 0:
117
@@ -XXX,XX +XXX,XX @@ static uint64_t read_pclk(QTestState *qts)
118
g_assert_not_reached();
119
}
120
121
- freq >>= (CLK2CKDIV(clkdiv1) + CLK4CKDIV(clkdiv1) + APB3CKDIV(clkdiv2));
122
+ freq >>= (CLK2CKDIV(clkdiv1) + CLK4CKDIV(clkdiv1) + apbdiv);
123
124
return freq;
125
}
126
@@ -XXX,XX +XXX,XX @@ static uint32_t pwm_selector(uint32_t csr)
127
static uint64_t pwm_compute_freq(QTestState *qts, uint32_t ppr, uint32_t csr,
128
uint32_t cnr)
129
{
130
- return read_pclk(qts) / ((ppr + 1) * pwm_selector(csr) * (cnr + 1));
131
+ return read_pclk(qts, false) / ((ppr + 1) * pwm_selector(csr) * (cnr + 1));
132
}
133
134
static uint64_t pwm_compute_duty(uint32_t cnr, uint32_t cmr, bool inverted)
135
@@ -XXX,XX +XXX,XX @@ static void pwm_write(QTestState *qts, const TestData *td, unsigned offset,
136
qtest_writel(qts, td->module->base_addr + offset, value);
137
}
138
139
+static uint8_t mft_readb(QTestState *qts, int index, unsigned offset)
140
+{
112
+{
141
+ return qtest_readb(qts, MFT_BA(index) + offset);
113
+ mc->desc = "Olimex STM32-H405 (Cortex-M4)";
114
+ mc->init = olimex_stm32_h405_init;
115
+ mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-m4");
116
+
117
+ /* SRAM pre-allocated as part of the SoC instantiation */
118
+ mc->default_ram_size = 0;
142
+}
119
+}
143
+
120
+
144
+static uint16_t mft_readw(QTestState *qts, int index, unsigned offset)
121
+DEFINE_MACHINE("olimex-stm32-h405", olimex_stm32_h405_machine_init)
145
+{
122
diff --git a/MAINTAINERS b/MAINTAINERS
146
+ return qtest_readw(qts, MFT_BA(index) + offset);
123
index XXXXXXX..XXXXXXX 100644
147
+}
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
148
+
135
+
149
+static void mft_writeb(QTestState *qts, int index, unsigned offset,
136
SmartFusion2
150
+ uint8_t value)
137
M: Subbaraya Sundeep <sundeep.lkml@gmail.com>
151
+{
138
M: Peter Maydell <peter.maydell@linaro.org>
152
+ qtest_writeb(qts, MFT_BA(index) + offset, value);
139
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
153
+}
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
154
+
150
+
155
+static void mft_writew(QTestState *qts, int index, unsigned offset,
151
config NSERIES
156
+ uint16_t value)
152
bool
157
+{
153
select OMAP
158
+ return qtest_writew(qts, MFT_BA(index) + offset, value);
154
diff --git a/hw/arm/meson.build b/hw/arm/meson.build
159
+}
155
index XXXXXXX..XXXXXXX 100644
160
+
156
--- a/hw/arm/meson.build
161
static uint32_t pwm_read_ppr(QTestState *qts, const TestData *td)
157
+++ b/hw/arm/meson.build
162
{
158
@@ -XXX,XX +XXX,XX @@ arm_ss.add(when: 'CONFIG_MICROBIT', if_true: files('microbit.c'))
163
return extract32(pwm_read(qts, td, PPR), ppr_base[pwm_index(td->pwm)], 8);
159
arm_ss.add(when: 'CONFIG_MUSICPAL', if_true: files('musicpal.c'))
164
@@ -XXX,XX +XXX,XX @@ static void pwm_write_cmr(QTestState *qts, const TestData *td, uint32_t value)
160
arm_ss.add(when: 'CONFIG_NETDUINO2', if_true: files('netduino2.c'))
165
pwm_write(qts, td, td->pwm->cmr_offset, value);
161
arm_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c'))
166
}
162
+arm_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c'))
167
163
arm_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c', 'npcm7xx_boards.c'))
168
+static int mft_compute_index(const TestData *td)
164
arm_ss.add(when: 'CONFIG_NSERIES', if_true: files('nseries.c'))
169
+{
165
arm_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c'))
170
+ int index = pwm_module_index(td->module) * ARRAY_SIZE(pwm_list) +
171
+ pwm_index(td->pwm);
172
+
173
+ g_assert_cmpint(index, <,
174
+ ARRAY_SIZE(pwm_module_list) * ARRAY_SIZE(pwm_list));
175
+
176
+ return index;
177
+}
178
+
179
+static void mft_reset_counters(QTestState *qts, int index)
180
+{
181
+ mft_writew(qts, index, MFT_CNT1, MFT_MAX_CNT);
182
+ mft_writew(qts, index, MFT_CNT2, MFT_MAX_CNT);
183
+ mft_writew(qts, index, MFT_CRA, MFT_MAX_CNT);
184
+ mft_writew(qts, index, MFT_CRB, MFT_MAX_CNT);
185
+ mft_writew(qts, index, MFT_CPA, MFT_MAX_CNT - MFT_TIMEOUT);
186
+ mft_writew(qts, index, MFT_CPB, MFT_MAX_CNT - MFT_TIMEOUT);
187
+}
188
+
189
+static void mft_init(QTestState *qts, const TestData *td)
190
+{
191
+ int index = mft_compute_index(td);
192
+
193
+ /* Enable everything */
194
+ mft_writeb(qts, index, MFT_CKC, 0);
195
+ mft_writeb(qts, index, MFT_ICLR, MFT_ICLR_ALL);
196
+ mft_writeb(qts, index, MFT_MCTRL, MFT_MCTRL_ALL);
197
+ mft_writeb(qts, index, MFT_IEN, MFT_IEN_ALL);
198
+ mft_writeb(qts, index, MFT_INASEL, 0);
199
+ mft_writeb(qts, index, MFT_INBSEL, 0);
200
+
201
+ /* Set cpcfg to use EQ mode, same as kernel driver */
202
+ mft_writeb(qts, index, MFT_CPCFG, MFT_CPCFG_EQ_MODE);
203
+
204
+ /* Write default counters, timeout and prescaler */
205
+ mft_reset_counters(qts, index);
206
+ mft_writeb(qts, index, MFT_PRSC, DEFAULT_PRSC);
207
+
208
+ /* Write default max rpm via QMP */
209
+ mft_qom_set(qts, index, "max_rpm[0]", DEFAULT_RPM);
210
+ mft_qom_set(qts, index, "max_rpm[1]", DEFAULT_RPM);
211
+}
212
+
213
+static int32_t mft_compute_cnt(uint32_t rpm, uint64_t clk)
214
+{
215
+ uint64_t cnt;
216
+
217
+ if (rpm == 0) {
218
+ return -1;
219
+ }
220
+
221
+ cnt = clk * 60 / ((DEFAULT_PRSC + 1) * rpm * MFT_PULSE_PER_REVOLUTION);
222
+ if (cnt >= MFT_TIMEOUT) {
223
+ return -1;
224
+ }
225
+ return MFT_MAX_CNT - cnt;
226
+}
227
+
228
+static void mft_verify_rpm(QTestState *qts, const TestData *td, uint64_t duty)
229
+{
230
+ int index = mft_compute_index(td);
231
+ uint16_t cnt, cr;
232
+ uint32_t rpm = DEFAULT_RPM * duty / MAX_DUTY;
233
+ uint64_t clk = read_pclk(qts, true);
234
+ int32_t expected_cnt = mft_compute_cnt(rpm, clk);
235
+
236
+ qtest_irq_intercept_in(qts, "/machine/soc/a9mpcore/gic");
237
+ g_test_message(
238
+ "verifying rpm for mft[%d]: clk: %lu, duty: %lu, rpm: %u, cnt: %d",
239
+ index, clk, duty, rpm, expected_cnt);
240
+
241
+ /* Verify rpm for fan A */
242
+ /* Stop capture */
243
+ mft_writeb(qts, index, MFT_CKC, 0);
244
+ mft_writeb(qts, index, MFT_ICLR, MFT_ICLR_ALL);
245
+ mft_reset_counters(qts, index);
246
+ g_assert_cmphex(mft_readw(qts, index, MFT_CNT1), ==, MFT_MAX_CNT);
247
+ g_assert_cmphex(mft_readw(qts, index, MFT_CRA), ==, MFT_MAX_CNT);
248
+ g_assert_cmphex(mft_readw(qts, index, MFT_CPA), ==,
249
+ MFT_MAX_CNT - MFT_TIMEOUT);
250
+ /* Start capture */
251
+ mft_writeb(qts, index, MFT_CKC, MFT_CKC_C1CSEL);
252
+ g_assert_true(qtest_get_irq(qts, MFT_IRQ(index)));
253
+ if (expected_cnt == -1) {
254
+ g_assert_cmphex(mft_readb(qts, index, MFT_ICTRL), ==, MFT_ICTRL_TEPND);
255
+ } else {
256
+ g_assert_cmphex(mft_readb(qts, index, MFT_ICTRL), ==, MFT_ICTRL_TAPND);
257
+ cnt = mft_readw(qts, index, MFT_CNT1);
258
+ /*
259
+ * Due to error in clock measurement and rounding, we might have a small
260
+ * error in measuring RPM.
261
+ */
262
+ g_assert_cmphex(cnt + MAX_ERROR, >=, expected_cnt);
263
+ g_assert_cmphex(cnt, <=, expected_cnt + MAX_ERROR);
264
+ cr = mft_readw(qts, index, MFT_CRA);
265
+ g_assert_cmphex(cnt, ==, cr);
266
+ }
267
+
268
+ /* Verify rpm for fan B */
269
+
270
+ qtest_irq_intercept_out(qts, "/machine/soc/a9mpcore/gic");
271
+}
272
+
273
/* Check pwm registers can be reset to default value */
274
static void test_init(gconstpointer test_data)
275
{
276
const TestData *td = test_data;
277
- QTestState *qts = qtest_init("-machine quanta-gsj");
278
+ QTestState *qts = qtest_init("-machine npcm750-evb");
279
int module = pwm_module_index(td->module);
280
int pwm = pwm_index(td->pwm);
281
282
@@ -XXX,XX +XXX,XX @@ static void test_init(gconstpointer test_data)
283
static void test_oneshot(gconstpointer test_data)
284
{
285
const TestData *td = test_data;
286
- QTestState *qts = qtest_init("-machine quanta-gsj");
287
+ QTestState *qts = qtest_init("-machine npcm750-evb");
288
int module = pwm_module_index(td->module);
289
int pwm = pwm_index(td->pwm);
290
uint32_t ppr, csr, pcr;
291
@@ -XXX,XX +XXX,XX @@ static void test_oneshot(gconstpointer test_data)
292
static void test_toggle(gconstpointer test_data)
293
{
294
const TestData *td = test_data;
295
- QTestState *qts = qtest_init("-machine quanta-gsj");
296
+ QTestState *qts = qtest_init("-machine npcm750-evb");
297
int module = pwm_module_index(td->module);
298
int pwm = pwm_index(td->pwm);
299
uint32_t ppr, csr, pcr, cnr, cmr;
300
int i, j, k, l;
301
uint64_t expected_freq, expected_duty;
302
303
+ mft_init(qts, td);
304
+
305
pcr = CH_EN | CH_MOD;
306
for (i = 0; i < ARRAY_SIZE(ppr_list); ++i) {
307
ppr = ppr_list[i];
308
@@ -XXX,XX +XXX,XX @@ static void test_toggle(gconstpointer test_data)
309
==, expected_freq);
310
}
311
312
+ /* Test MFT's RPM is correct. */
313
+ mft_verify_rpm(qts, td, expected_duty);
314
+
315
/* Test inverted mode */
316
expected_duty = pwm_compute_duty(cnr, cmr, true);
317
pwm_write_pcr(qts, td, pcr | CH_INV);
318
--
166
--
319
2.20.1
167
2.34.1
320
168
321
169
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
This patch implements Multi Function Timer (MFT) module for NPCM7XX.
3
During SPL boot several Clock Controller Module (CCM) registers are
4
This module is mainly used to configure PWM fans. It has just enough
4
read, most important are PLL and Tuning, as well as divisor registers.
5
functionality to make the PWM fan kernel module work.
6
5
7
The module takes two input, the max_rpm of a fan (modifiable via QMP)
6
This patch adds these registers and initializes reset values from user's
8
and duty cycle (a GPIO from the PWM module.) The actual measured RPM
7
guide.
9
is equal to max_rpm * duty_cycle / NPCM7XX_PWM_MAX_DUTY. The RPM is
10
measured as a counter compared to a prescaled input clock. The kernel
11
driver reads this counter and report to user space.
12
8
13
Refs:
9
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
14
https://github.com/torvalds/linux/blob/master/drivers/hwmon/npcm750-pwm-fan.c
15
10
16
Reviewed-by: Doug Evans <dje@google.com>
11
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
17
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
12
Message-id: 20221226220303.14420-2-strahinja.p.jankovic@gmail.com
18
Signed-off-by: Hao Wu <wuhaotsh@google.com>
19
Message-id: 20210311180855.149764-3-wuhaotsh@google.com
20
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
21
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
22
---
14
---
23
include/hw/misc/npcm7xx_mft.h | 70 +++++
15
include/hw/arm/allwinner-a10.h | 2 +
24
hw/misc/npcm7xx_mft.c | 540 ++++++++++++++++++++++++++++++++++
16
include/hw/misc/allwinner-a10-ccm.h | 67 +++++++++
25
hw/misc/meson.build | 1 +
17
hw/arm/allwinner-a10.c | 7 +
26
hw/misc/trace-events | 8 +
18
hw/misc/allwinner-a10-ccm.c | 224 ++++++++++++++++++++++++++++
27
4 files changed, 619 insertions(+)
19
hw/arm/Kconfig | 1 +
28
create mode 100644 include/hw/misc/npcm7xx_mft.h
20
hw/misc/Kconfig | 3 +
29
create mode 100644 hw/misc/npcm7xx_mft.c
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
30
25
31
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
26
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
27
index XXXXXXX..XXXXXXX 100644
28
--- a/include/hw/arm/allwinner-a10.h
29
+++ b/include/hw/arm/allwinner-a10.h
30
@@ -XXX,XX +XXX,XX @@
31
#include "hw/usb/hcd-ohci.h"
32
#include "hw/usb/hcd-ehci.h"
33
#include "hw/rtc/allwinner-rtc.h"
34
+#include "hw/misc/allwinner-a10-ccm.h"
35
36
#include "target/arm/cpu.h"
37
#include "qom/object.h"
38
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
39
/*< public >*/
40
41
ARMCPU cpu;
42
+ AwA10ClockCtlState ccm;
43
AwA10PITState timer;
44
AwA10PICState intc;
45
AwEmacState emac;
46
diff --git a/include/hw/misc/allwinner-a10-ccm.h b/include/hw/misc/allwinner-a10-ccm.h
32
new file mode 100644
47
new file mode 100644
33
index XXXXXXX..XXXXXXX
48
index XXXXXXX..XXXXXXX
34
--- /dev/null
49
--- /dev/null
35
+++ b/include/hw/misc/npcm7xx_mft.h
50
+++ b/include/hw/misc/allwinner-a10-ccm.h
36
@@ -XXX,XX +XXX,XX @@
51
@@ -XXX,XX +XXX,XX @@
37
+/*
52
+/*
38
+ * Nuvoton NPCM7xx MFT Module
53
+ * Allwinner A10 Clock Control Module emulation
39
+ *
54
+ *
40
+ * Copyright 2021 Google LLC
55
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
41
+ *
56
+ *
42
+ * This program is free software; you can redistribute it and/or modify it
57
+ * This file is derived from Allwinner H3 CCU,
43
+ * under the terms of the GNU General Public License as published by the
58
+ * by Niek Linnenbank.
44
+ * Free Software Foundation; either version 2 of the License, or
59
+ *
60
+ * This program is free software: you can redistribute it and/or modify
61
+ * it under the terms of the GNU General Public License as published by
62
+ * the Free Software Foundation, either version 2 of the License, or
45
+ * (at your option) any later version.
63
+ * (at your option) any later version.
46
+ *
64
+ *
47
+ * This program is distributed in the hope that it will be useful, but WITHOUT
65
+ * This program is distributed in the hope that it will be useful,
48
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
66
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
49
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
67
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50
+ * for more details.
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/>.
51
+ */
72
+ */
52
+#ifndef NPCM7XX_MFT_H
73
+
53
+#define NPCM7XX_MFT_H
74
+#ifndef HW_MISC_ALLWINNER_A10_CCM_H
54
+
75
+#define HW_MISC_ALLWINNER_A10_CCM_H
55
+#include "exec/memory.h"
76
+
56
+#include "hw/clock.h"
77
+#include "qom/object.h"
57
+#include "hw/irq.h"
58
+#include "hw/sysbus.h"
78
+#include "hw/sysbus.h"
59
+#include "qom/object.h"
79
+
60
+
80
+/**
61
+/* Max Fan input number. */
81
+ * @name Constants
62
+#define NPCM7XX_MFT_MAX_FAN_INPUT 19
82
+ * @{
63
+
64
+/*
65
+ * Number of registers in one MFT module. Don't change this without increasing
66
+ * the version_id in vmstate.
67
+ */
83
+ */
68
+#define NPCM7XX_MFT_NR_REGS (0x20 / sizeof(uint16_t))
84
+
69
+
85
+/** Size of register I/O address space used by CCM device */
70
+/*
86
+#define AW_A10_CCM_IOSIZE (0x400)
71
+ * The MFT can take up to 4 inputs: A0, B0, A1, B1. It can measure one A and one
87
+
72
+ * B simultaneously. NPCM7XX_MFT_INASEL and NPCM7XX_MFT_INBSEL are used to
88
+/** Total number of known registers */
73
+ * select which A or B input are used.
89
+#define AW_A10_CCM_REGS_NUM (AW_A10_CCM_IOSIZE / sizeof(uint32_t))
90
+
91
+/** @} */
92
+
93
+/**
94
+ * @name Object model
95
+ * @{
74
+ */
96
+ */
75
+#define NPCM7XX_MFT_FANIN_COUNT 4
97
+
98
+#define TYPE_AW_A10_CCM "allwinner-a10-ccm"
99
+OBJECT_DECLARE_SIMPLE_TYPE(AwA10ClockCtlState, AW_A10_CCM)
100
+
101
+/** @} */
76
+
102
+
77
+/**
103
+/**
78
+ * struct NPCM7xxMFTState - Multi Functional Tachometer device state.
104
+ * Allwinner A10 CCM object instance state.
79
+ * @parent: System bus device.
80
+ * @iomem: Memory region through which registers are accessed.
81
+ * @clock_in: The input clock for MFT from CLK module.
82
+ * @clock_{1,2}: The counter clocks for NPCM7XX_MFT_CNT{1,2}
83
+ * @irq: The IRQ for this MFT state.
84
+ * @regs: The MMIO registers.
85
+ * @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1.
86
+ * @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY.
87
+ */
105
+ */
88
+typedef struct NPCM7xxMFTState {
106
+struct AwA10ClockCtlState {
89
+ SysBusDevice parent;
107
+ /*< private >*/
90
+
108
+ SysBusDevice parent_obj;
109
+ /*< public >*/
110
+
111
+ /** Maps I/O registers in physical memory */
91
+ MemoryRegion iomem;
112
+ MemoryRegion iomem;
92
+
113
+
93
+ Clock *clock_in;
114
+ /** Array of hardware registers */
94
+ Clock *clock_1, *clock_2;
115
+ uint32_t regs[AW_A10_CCM_REGS_NUM];
95
+ qemu_irq irq;
116
+};
96
+ uint16_t regs[NPCM7XX_MFT_NR_REGS];
117
+
97
+
118
+#endif /* HW_MISC_ALLWINNER_H3_CCU_H */
98
+ uint32_t max_rpm[NPCM7XX_MFT_FANIN_COUNT];
119
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
99
+ uint32_t duty[NPCM7XX_MFT_FANIN_COUNT];
120
index XXXXXXX..XXXXXXX 100644
100
+} NPCM7xxMFTState;
121
--- a/hw/arm/allwinner-a10.c
101
+
122
+++ b/hw/arm/allwinner-a10.c
102
+#define TYPE_NPCM7XX_MFT "npcm7xx-mft"
123
@@ -XXX,XX +XXX,XX @@
103
+#define NPCM7XX_MFT(obj) \
124
#include "hw/usb/hcd-ohci.h"
104
+ OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT)
125
105
+
126
#define AW_A10_MMC0_BASE 0x01c0f000
106
+#endif /* NPCM7XX_MFT_H */
127
+#define AW_A10_CCM_BASE 0x01c20000
107
diff --git a/hw/misc/npcm7xx_mft.c b/hw/misc/npcm7xx_mft.c
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
108
new file mode 100644
152
new file mode 100644
109
index XXXXXXX..XXXXXXX
153
index XXXXXXX..XXXXXXX
110
--- /dev/null
154
--- /dev/null
111
+++ b/hw/misc/npcm7xx_mft.c
155
+++ b/hw/misc/allwinner-a10-ccm.c
112
@@ -XXX,XX +XXX,XX @@
156
@@ -XXX,XX +XXX,XX @@
113
+/*
157
+/*
114
+ * Nuvoton NPCM7xx MFT Module
158
+ * Allwinner A10 Clock Control Module emulation
115
+ *
159
+ *
116
+ * Copyright 2021 Google LLC
160
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
117
+ *
161
+ *
118
+ * This program is free software; you can redistribute it and/or modify it
162
+ * This file is derived from Allwinner H3 CCU,
119
+ * under the terms of the GNU General Public License as published by the
163
+ * by Niek Linnenbank.
120
+ * Free Software Foundation; either version 2 of the License, or
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
121
+ * (at your option) any later version.
168
+ * (at your option) any later version.
122
+ *
169
+ *
123
+ * This program is distributed in the hope that it will be useful, but WITHOUT
170
+ * This program is distributed in the hope that it will be useful,
124
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
171
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
125
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
172
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
126
+ * for more details.
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/>.
127
+ */
177
+ */
128
+
178
+
129
+#include "qemu/osdep.h"
179
+#include "qemu/osdep.h"
130
+#include "hw/irq.h"
180
+#include "qemu/units.h"
131
+#include "hw/qdev-clock.h"
181
+#include "hw/sysbus.h"
132
+#include "hw/qdev-properties.h"
133
+#include "hw/misc/npcm7xx_mft.h"
134
+#include "hw/misc/npcm7xx_pwm.h"
135
+#include "hw/registerfields.h"
136
+#include "migration/vmstate.h"
182
+#include "migration/vmstate.h"
137
+#include "qapi/error.h"
138
+#include "qapi/visitor.h"
139
+#include "qemu/bitops.h"
140
+#include "qemu/error-report.h"
141
+#include "qemu/log.h"
183
+#include "qemu/log.h"
142
+#include "qemu/module.h"
184
+#include "qemu/module.h"
143
+#include "qemu/timer.h"
185
+#include "hw/misc/allwinner-a10-ccm.h"
144
+#include "qemu/units.h"
186
+
145
+#include "trace.h"
187
+/* CCM register offsets */
146
+
188
+enum {
147
+/*
189
+ REG_PLL1_CFG = 0x0000, /* PLL1 Control */
148
+ * Some of the registers can only accessed via 16-bit ops and some can only
190
+ REG_PLL1_TUN = 0x0004, /* PLL1 Tuning */
149
+ * be accessed via 8-bit ops. However we mark all of them using REG16 to
191
+ REG_PLL2_CFG = 0x0008, /* PLL2 Control */
150
+ * simplify implementation. npcm7xx_mft_check_mem_op checks the access length
192
+ REG_PLL2_TUN = 0x000C, /* PLL2 Tuning */
151
+ * of memory operations.
193
+ REG_PLL3_CFG = 0x0010, /* PLL3 Control */
152
+ */
194
+ REG_PLL4_CFG = 0x0018, /* PLL4 Control */
153
+REG16(NPCM7XX_MFT_CNT1, 0x00);
195
+ REG_PLL5_CFG = 0x0020, /* PLL5 Control */
154
+REG16(NPCM7XX_MFT_CRA, 0x02);
196
+ REG_PLL5_TUN = 0x0024, /* PLL5 Tuning */
155
+REG16(NPCM7XX_MFT_CRB, 0x04);
197
+ REG_PLL6_CFG = 0x0028, /* PLL6 Control */
156
+REG16(NPCM7XX_MFT_CNT2, 0x06);
198
+ REG_PLL6_TUN = 0x002C, /* PLL6 Tuning */
157
+REG16(NPCM7XX_MFT_PRSC, 0x08);
199
+ REG_PLL7_CFG = 0x0030, /* PLL7 Control */
158
+REG16(NPCM7XX_MFT_CKC, 0x0a);
200
+ REG_PLL1_TUN2 = 0x0038, /* PLL1 Tuning2 */
159
+REG16(NPCM7XX_MFT_MCTRL, 0x0c);
201
+ REG_PLL5_TUN2 = 0x003C, /* PLL5 Tuning2 */
160
+REG16(NPCM7XX_MFT_ICTRL, 0x0e);
202
+ REG_PLL8_CFG = 0x0040, /* PLL8 Control */
161
+REG16(NPCM7XX_MFT_ICLR, 0x10);
203
+ REG_OSC24M_CFG = 0x0050, /* OSC24M Control */
162
+REG16(NPCM7XX_MFT_IEN, 0x12);
204
+ REG_CPU_AHB_APB0_CFG = 0x0054, /* CPU, AHB and APB0 Divide Ratio */
163
+REG16(NPCM7XX_MFT_CPA, 0x14);
205
+};
164
+REG16(NPCM7XX_MFT_CPB, 0x16);
206
+
165
+REG16(NPCM7XX_MFT_CPCFG, 0x18);
207
+#define REG_INDEX(offset) (offset / sizeof(uint32_t))
166
+REG16(NPCM7XX_MFT_INASEL, 0x1a);
208
+
167
+REG16(NPCM7XX_MFT_INBSEL, 0x1c);
209
+/* CCM register reset values */
168
+
210
+enum {
169
+/* Register Fields */
211
+ REG_PLL1_CFG_RST = 0x21005000,
170
+#define NPCM7XX_MFT_CKC_C2CSEL BIT(3)
212
+ REG_PLL1_TUN_RST = 0x0A101000,
171
+#define NPCM7XX_MFT_CKC_C1CSEL BIT(0)
213
+ REG_PLL2_CFG_RST = 0x08100010,
172
+
214
+ REG_PLL2_TUN_RST = 0x00000000,
173
+#define NPCM7XX_MFT_MCTRL_TBEN BIT(6)
215
+ REG_PLL3_CFG_RST = 0x0010D063,
174
+#define NPCM7XX_MFT_MCTRL_TAEN BIT(5)
216
+ REG_PLL4_CFG_RST = 0x21009911,
175
+#define NPCM7XX_MFT_MCTRL_TBEDG BIT(4)
217
+ REG_PLL5_CFG_RST = 0x11049280,
176
+#define NPCM7XX_MFT_MCTRL_TAEDG BIT(3)
218
+ REG_PLL5_TUN_RST = 0x14888000,
177
+#define NPCM7XX_MFT_MCTRL_MODE5 BIT(2)
219
+ REG_PLL6_CFG_RST = 0x21009911,
178
+
220
+ REG_PLL6_TUN_RST = 0x00000000,
179
+#define NPCM7XX_MFT_ICTRL_TFPND BIT(5)
221
+ REG_PLL7_CFG_RST = 0x0010D063,
180
+#define NPCM7XX_MFT_ICTRL_TEPND BIT(4)
222
+ REG_PLL1_TUN2_RST = 0x00000000,
181
+#define NPCM7XX_MFT_ICTRL_TDPND BIT(3)
223
+ REG_PLL5_TUN2_RST = 0x00000000,
182
+#define NPCM7XX_MFT_ICTRL_TCPND BIT(2)
224
+ REG_PLL8_CFG_RST = 0x21009911,
183
+#define NPCM7XX_MFT_ICTRL_TBPND BIT(1)
225
+ REG_OSC24M_CFG_RST = 0x00138013,
184
+#define NPCM7XX_MFT_ICTRL_TAPND BIT(0)
226
+ REG_CPU_AHB_APB0_CFG_RST = 0x00010010,
185
+
227
+};
186
+#define NPCM7XX_MFT_ICLR_TFCLR BIT(5)
228
+
187
+#define NPCM7XX_MFT_ICLR_TECLR BIT(4)
229
+static uint64_t allwinner_a10_ccm_read(void *opaque, hwaddr offset,
188
+#define NPCM7XX_MFT_ICLR_TDCLR BIT(3)
230
+ unsigned size)
189
+#define NPCM7XX_MFT_ICLR_TCCLR BIT(2)
231
+{
190
+#define NPCM7XX_MFT_ICLR_TBCLR BIT(1)
232
+ const AwA10ClockCtlState *s = AW_A10_CCM(opaque);
191
+#define NPCM7XX_MFT_ICLR_TACLR BIT(0)
233
+ const uint32_t idx = REG_INDEX(offset);
192
+
234
+
193
+#define NPCM7XX_MFT_IEN_TFIEN BIT(5)
235
+ switch (offset) {
194
+#define NPCM7XX_MFT_IEN_TEIEN BIT(4)
236
+ case REG_PLL1_CFG:
195
+#define NPCM7XX_MFT_IEN_TDIEN BIT(3)
237
+ case REG_PLL1_TUN:
196
+#define NPCM7XX_MFT_IEN_TCIEN BIT(2)
238
+ case REG_PLL2_CFG:
197
+#define NPCM7XX_MFT_IEN_TBIEN BIT(1)
239
+ case REG_PLL2_TUN:
198
+#define NPCM7XX_MFT_IEN_TAIEN BIT(0)
240
+ case REG_PLL3_CFG:
199
+
241
+ case REG_PLL4_CFG:
200
+#define NPCM7XX_MFT_CPCFG_GET_B(rv) extract8((rv), 4, 4)
242
+ case REG_PLL5_CFG:
201
+#define NPCM7XX_MFT_CPCFG_GET_A(rv) extract8((rv), 0, 4)
243
+ case REG_PLL5_TUN:
202
+#define NPCM7XX_MFT_CPCFG_HIEN BIT(3)
244
+ case REG_PLL6_CFG:
203
+#define NPCM7XX_MFT_CPCFG_EQEN BIT(2)
245
+ case REG_PLL6_TUN:
204
+#define NPCM7XX_MFT_CPCFG_LOEN BIT(1)
246
+ case REG_PLL7_CFG:
205
+#define NPCM7XX_MFT_CPCFG_CPSEL BIT(0)
247
+ case REG_PLL1_TUN2:
206
+
248
+ case REG_PLL5_TUN2:
207
+#define NPCM7XX_MFT_INASEL_SELA BIT(0)
249
+ case REG_PLL8_CFG:
208
+#define NPCM7XX_MFT_INBSEL_SELB BIT(0)
250
+ case REG_OSC24M_CFG:
209
+
251
+ case REG_CPU_AHB_APB0_CFG:
210
+/* Max CNT values of the module. The CNT value is a countdown from it. */
252
+ break;
211
+#define NPCM7XX_MFT_MAX_CNT 0xFFFF
253
+ case 0x158 ... AW_A10_CCM_IOSIZE:
212
+
254
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
213
+/* Each fan revolution should generated 2 pulses */
255
+ __func__, (uint32_t)offset);
214
+#define NPCM7XX_MFT_PULSE_PER_REVOLUTION 2
256
+ return 0;
215
+
257
+ default:
216
+typedef enum NPCM7xxMFTCaptureState {
258
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented read offset 0x%04x\n",
217
+ /* capture succeeded with a valid CNT value. */
259
+ __func__, (uint32_t)offset);
218
+ NPCM7XX_CAPTURE_SUCCEED,
260
+ return 0;
219
+ /* capture stopped prematurely due to reaching CPCFG condition. */
220
+ NPCM7XX_CAPTURE_COMPARE_HIT,
221
+ /* capture fails since it reaches underflow condition for CNT. */
222
+ NPCM7XX_CAPTURE_UNDERFLOW,
223
+} NPCM7xxMFTCaptureState;
224
+
225
+static void npcm7xx_mft_reset(NPCM7xxMFTState *s)
226
+{
227
+ int i;
228
+
229
+ /* Only registers PRSC ~ INBSEL need to be reset. */
230
+ for (i = R_NPCM7XX_MFT_PRSC; i <= R_NPCM7XX_MFT_INBSEL; ++i) {
231
+ s->regs[i] = 0;
232
+ }
261
+ }
233
+}
262
+
234
+
263
+ return s->regs[idx];
235
+static void npcm7xx_mft_clear_interrupt(NPCM7xxMFTState *s, uint8_t iclr)
264
+}
236
+{
265
+
237
+ /*
266
+static void allwinner_a10_ccm_write(void *opaque, hwaddr offset,
238
+ * Clear bits in ICTRL where corresponding bits in iclr is 1.
267
+ uint64_t val, unsigned size)
239
+ * Both iclr and ictrl are 8-bit regs. (See npcm7xx_mft_check_mem_op)
268
+{
240
+ */
269
+ AwA10ClockCtlState *s = AW_A10_CCM(opaque);
241
+ s->regs[R_NPCM7XX_MFT_ICTRL] &= ~iclr;
270
+ const uint32_t idx = REG_INDEX(offset);
242
+}
243
+
244
+/*
245
+ * If the CPCFG's condition should be triggered during count down from
246
+ * NPCM7XX_MFT_MAX_CNT to src if compared to tgt, return the count when
247
+ * the condition is triggered.
248
+ * Otherwise return -1.
249
+ * Since tgt is uint16_t it must always <= NPCM7XX_MFT_MAX_CNT.
250
+ */
251
+static int npcm7xx_mft_compare(int32_t src, uint16_t tgt, uint8_t cpcfg)
252
+{
253
+ if (cpcfg & NPCM7XX_MFT_CPCFG_HIEN) {
254
+ return NPCM7XX_MFT_MAX_CNT;
255
+ }
256
+ if ((cpcfg & NPCM7XX_MFT_CPCFG_EQEN) && (src <= tgt)) {
257
+ return tgt;
258
+ }
259
+ if ((cpcfg & NPCM7XX_MFT_CPCFG_LOEN) && (tgt > 0) && (src < tgt)) {
260
+ return tgt - 1;
261
+ }
262
+
263
+ return -1;
264
+}
265
+
266
+/* Compute CNT according to corresponding fan's RPM. */
267
+static NPCM7xxMFTCaptureState npcm7xx_mft_compute_cnt(
268
+ Clock *clock, uint32_t max_rpm, uint32_t duty, uint16_t tgt,
269
+ uint8_t cpcfg, uint16_t *cnt)
270
+{
271
+ uint32_t rpm = (uint64_t)max_rpm * (uint64_t)duty / NPCM7XX_PWM_MAX_DUTY;
272
+ int32_t count;
273
+ int stopped;
274
+ NPCM7xxMFTCaptureState state;
275
+
276
+ if (rpm == 0) {
277
+ /*
278
+ * If RPM = 0, capture won't happen. CNT will continue count down.
279
+ * So it's effective equivalent to have a cnt > NPCM7XX_MFT_MAX_CNT
280
+ */
281
+ count = NPCM7XX_MFT_MAX_CNT + 1;
282
+ } else {
283
+ /*
284
+ * RPM = revolution/min. The time for one revlution (in ns) is
285
+ * MINUTE_TO_NANOSECOND / RPM.
286
+ */
287
+ count = clock_ns_to_ticks(clock, (60 * NANOSECONDS_PER_SECOND) /
288
+ (rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION));
289
+ }
290
+
291
+ if (count > NPCM7XX_MFT_MAX_CNT) {
292
+ count = -1;
293
+ } else {
294
+ /* The CNT is a countdown value from NPCM7XX_MFT_MAX_CNT. */
295
+ count = NPCM7XX_MFT_MAX_CNT - count;
296
+ }
297
+ stopped = npcm7xx_mft_compare(count, tgt, cpcfg);
298
+ if (stopped == -1) {
299
+ if (count == -1) {
300
+ /* Underflow */
301
+ state = NPCM7XX_CAPTURE_UNDERFLOW;
302
+ } else {
303
+ state = NPCM7XX_CAPTURE_SUCCEED;
304
+ }
305
+ } else {
306
+ count = stopped;
307
+ state = NPCM7XX_CAPTURE_COMPARE_HIT;
308
+ }
309
+
310
+ if (count != -1) {
311
+ *cnt = count;
312
+ }
313
+ trace_npcm7xx_mft_rpm(clock->canonical_path, clock_get_hz(clock),
314
+ state, count, rpm, duty);
315
+ return state;
316
+}
317
+
318
+/*
319
+ * Capture Fan RPM and update CNT and CR registers accordingly.
320
+ * Raise IRQ if certain contidions are met in IEN.
321
+ */
322
+static void npcm7xx_mft_capture(NPCM7xxMFTState *s)
323
+{
324
+ int irq_level = 0;
325
+ NPCM7xxMFTCaptureState state;
326
+ int sel;
327
+ uint8_t cpcfg;
328
+
329
+ /*
330
+ * If not mode 5, the behavior is undefined. We just do nothing in this
331
+ * case.
332
+ */
333
+ if (!(s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_MODE5)) {
334
+ return;
335
+ }
336
+
337
+ /* Capture input A. */
338
+ if (s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_TAEN &&
339
+ s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C1CSEL) {
340
+ sel = s->regs[R_NPCM7XX_MFT_INASEL] & NPCM7XX_MFT_INASEL_SELA;
341
+ cpcfg = NPCM7XX_MFT_CPCFG_GET_A(s->regs[R_NPCM7XX_MFT_CPCFG]);
342
+ state = npcm7xx_mft_compute_cnt(s->clock_1,
343
+ sel ? s->max_rpm[2] : s->max_rpm[0],
344
+ sel ? s->duty[2] : s->duty[0],
345
+ s->regs[R_NPCM7XX_MFT_CPA],
346
+ cpcfg,
347
+ &s->regs[R_NPCM7XX_MFT_CNT1]);
348
+ switch (state) {
349
+ case NPCM7XX_CAPTURE_SUCCEED:
350
+ /* Interrupt on input capture on TAn transition - TAPND */
351
+ s->regs[R_NPCM7XX_MFT_CRA] = s->regs[R_NPCM7XX_MFT_CNT1];
352
+ s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TAPND;
353
+ if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TAIEN) {
354
+ irq_level = 1;
355
+ }
356
+ break;
357
+
358
+ case NPCM7XX_CAPTURE_COMPARE_HIT:
359
+ /* Compare Hit - TEPND */
360
+ s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TEPND;
361
+ if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TEIEN) {
362
+ irq_level = 1;
363
+ }
364
+ break;
365
+
366
+ case NPCM7XX_CAPTURE_UNDERFLOW:
367
+ /* Underflow - TCPND */
368
+ s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TCPND;
369
+ if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TCIEN) {
370
+ irq_level = 1;
371
+ }
372
+ break;
373
+
374
+ default:
375
+ g_assert_not_reached();
376
+ }
377
+ }
378
+
379
+ /* Capture input B. */
380
+ if (s->regs[R_NPCM7XX_MFT_MCTRL] & NPCM7XX_MFT_MCTRL_TBEN &&
381
+ s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C2CSEL) {
382
+ sel = s->regs[R_NPCM7XX_MFT_INBSEL] & NPCM7XX_MFT_INBSEL_SELB;
383
+ cpcfg = NPCM7XX_MFT_CPCFG_GET_B(s->regs[R_NPCM7XX_MFT_CPCFG]);
384
+ state = npcm7xx_mft_compute_cnt(s->clock_2,
385
+ sel ? s->max_rpm[3] : s->max_rpm[1],
386
+ sel ? s->duty[3] : s->duty[1],
387
+ s->regs[R_NPCM7XX_MFT_CPB],
388
+ cpcfg,
389
+ &s->regs[R_NPCM7XX_MFT_CNT2]);
390
+ switch (state) {
391
+ case NPCM7XX_CAPTURE_SUCCEED:
392
+ /* Interrupt on input capture on TBn transition - TBPND */
393
+ s->regs[R_NPCM7XX_MFT_CRB] = s->regs[R_NPCM7XX_MFT_CNT2];
394
+ s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TBPND;
395
+ if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TBIEN) {
396
+ irq_level = 1;
397
+ }
398
+ break;
399
+
400
+ case NPCM7XX_CAPTURE_COMPARE_HIT:
401
+ /* Compare Hit - TFPND */
402
+ s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TFPND;
403
+ if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TFIEN) {
404
+ irq_level = 1;
405
+ }
406
+ break;
407
+
408
+ case NPCM7XX_CAPTURE_UNDERFLOW:
409
+ /* Underflow - TDPND */
410
+ s->regs[R_NPCM7XX_MFT_ICTRL] |= NPCM7XX_MFT_ICTRL_TDPND;
411
+ if (s->regs[R_NPCM7XX_MFT_IEN] & NPCM7XX_MFT_IEN_TDIEN) {
412
+ irq_level = 1;
413
+ }
414
+ break;
415
+
416
+ default:
417
+ g_assert_not_reached();
418
+ }
419
+ }
420
+
421
+ trace_npcm7xx_mft_capture(DEVICE(s)->canonical_path, irq_level);
422
+ qemu_set_irq(s->irq, irq_level);
423
+}
424
+
425
+/* Update clock for counters. */
426
+static void npcm7xx_mft_update_clock(void *opaque, ClockEvent event)
427
+{
428
+ NPCM7xxMFTState *s = NPCM7XX_MFT(opaque);
429
+ uint64_t prescaled_clock_period;
430
+
431
+ prescaled_clock_period = clock_get(s->clock_in) *
432
+ (s->regs[R_NPCM7XX_MFT_PRSC] + 1ULL);
433
+ trace_npcm7xx_mft_update_clock(s->clock_in->canonical_path,
434
+ s->regs[R_NPCM7XX_MFT_CKC],
435
+ clock_get(s->clock_in),
436
+ prescaled_clock_period);
437
+ /* Update clock 1 */
438
+ if (s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C1CSEL) {
439
+ /* Clock is prescaled. */
440
+ clock_update(s->clock_1, prescaled_clock_period);
441
+ } else {
442
+ /* Clock stopped. */
443
+ clock_update(s->clock_1, 0);
444
+ }
445
+ /* Update clock 2 */
446
+ if (s->regs[R_NPCM7XX_MFT_CKC] & NPCM7XX_MFT_CKC_C2CSEL) {
447
+ /* Clock is prescaled. */
448
+ clock_update(s->clock_2, prescaled_clock_period);
449
+ } else {
450
+ /* Clock stopped. */
451
+ clock_update(s->clock_2, 0);
452
+ }
453
+
454
+ npcm7xx_mft_capture(s);
455
+}
456
+
457
+static uint64_t npcm7xx_mft_read(void *opaque, hwaddr offset, unsigned size)
458
+{
459
+ NPCM7xxMFTState *s = NPCM7XX_MFT(opaque);
460
+ uint16_t value = 0;
461
+
271
+
462
+ switch (offset) {
272
+ switch (offset) {
463
+ case A_NPCM7XX_MFT_ICLR:
273
+ case REG_PLL1_CFG:
464
+ qemu_log_mask(LOG_GUEST_ERROR,
274
+ case REG_PLL1_TUN:
465
+ "%s: register @ 0x%04" HWADDR_PRIx " is write-only\n",
275
+ case REG_PLL2_CFG:
466
+ __func__, offset);
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:
467
+ break;
289
+ break;
468
+
290
+ case 0x158 ... AW_A10_CCM_IOSIZE:
291
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
292
+ __func__, (uint32_t)offset);
293
+ break;
469
+ default:
294
+ default:
470
+ value = s->regs[offset / 2];
295
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented write offset 0x%04x\n",
471
+ }
296
+ __func__, (uint32_t)offset);
472
+
473
+ trace_npcm7xx_mft_read(DEVICE(s)->canonical_path, offset, value);
474
+ return value;
475
+}
476
+
477
+static void npcm7xx_mft_write(void *opaque, hwaddr offset,
478
+ uint64_t v, unsigned size)
479
+{
480
+ NPCM7xxMFTState *s = NPCM7XX_MFT(opaque);
481
+
482
+ trace_npcm7xx_mft_write(DEVICE(s)->canonical_path, offset, v);
483
+ switch (offset) {
484
+ case A_NPCM7XX_MFT_ICLR:
485
+ npcm7xx_mft_clear_interrupt(s, v);
486
+ break;
487
+
488
+ case A_NPCM7XX_MFT_CKC:
489
+ case A_NPCM7XX_MFT_PRSC:
490
+ s->regs[offset / 2] = v;
491
+ npcm7xx_mft_update_clock(s, ClockUpdate);
492
+ break;
493
+
494
+ default:
495
+ s->regs[offset / 2] = v;
496
+ npcm7xx_mft_capture(s);
497
+ break;
297
+ break;
498
+ }
298
+ }
499
+}
299
+
500
+
300
+ s->regs[idx] = (uint32_t) val;
501
+static bool npcm7xx_mft_check_mem_op(void *opaque, hwaddr offset,
301
+}
502
+ unsigned size, bool is_write,
302
+
503
+ MemTxAttrs attrs)
303
+static const MemoryRegionOps allwinner_a10_ccm_ops = {
504
+{
304
+ .read = allwinner_a10_ccm_read,
505
+ switch (offset) {
305
+ .write = allwinner_a10_ccm_write,
506
+ /* 16-bit registers. Must be accessed with 16-bit read/write.*/
306
+ .endianness = DEVICE_NATIVE_ENDIAN,
507
+ case A_NPCM7XX_MFT_CNT1:
307
+ .valid = {
508
+ case A_NPCM7XX_MFT_CRA:
308
+ .min_access_size = 4,
509
+ case A_NPCM7XX_MFT_CRB:
309
+ .max_access_size = 4,
510
+ case A_NPCM7XX_MFT_CNT2:
310
+ },
511
+ case A_NPCM7XX_MFT_CPA:
311
+ .impl.min_access_size = 4,
512
+ case A_NPCM7XX_MFT_CPB:
312
+};
513
+ return size == 2;
313
+
514
+
314
+static void allwinner_a10_ccm_reset_enter(Object *obj, ResetType type)
515
+ /* 8-bit registers. Must be accessed with 8-bit read/write.*/
315
+{
516
+ case A_NPCM7XX_MFT_PRSC:
316
+ AwA10ClockCtlState *s = AW_A10_CCM(obj);
517
+ case A_NPCM7XX_MFT_CKC:
317
+
518
+ case A_NPCM7XX_MFT_MCTRL:
318
+ /* Set default values for registers */
519
+ case A_NPCM7XX_MFT_ICTRL:
319
+ s->regs[REG_INDEX(REG_PLL1_CFG)] = REG_PLL1_CFG_RST;
520
+ case A_NPCM7XX_MFT_ICLR:
320
+ s->regs[REG_INDEX(REG_PLL1_TUN)] = REG_PLL1_TUN_RST;
521
+ case A_NPCM7XX_MFT_IEN:
321
+ s->regs[REG_INDEX(REG_PLL2_CFG)] = REG_PLL2_CFG_RST;
522
+ case A_NPCM7XX_MFT_CPCFG:
322
+ s->regs[REG_INDEX(REG_PLL2_TUN)] = REG_PLL2_TUN_RST;
523
+ case A_NPCM7XX_MFT_INASEL:
323
+ s->regs[REG_INDEX(REG_PLL3_CFG)] = REG_PLL3_CFG_RST;
524
+ case A_NPCM7XX_MFT_INBSEL:
324
+ s->regs[REG_INDEX(REG_PLL4_CFG)] = REG_PLL4_CFG_RST;
525
+ return size == 1;
325
+ s->regs[REG_INDEX(REG_PLL5_CFG)] = REG_PLL5_CFG_RST;
526
+
326
+ s->regs[REG_INDEX(REG_PLL5_TUN)] = REG_PLL5_TUN_RST;
527
+ default:
327
+ s->regs[REG_INDEX(REG_PLL6_CFG)] = REG_PLL6_CFG_RST;
528
+ /* Invalid registers. */
328
+ s->regs[REG_INDEX(REG_PLL6_TUN)] = REG_PLL6_TUN_RST;
529
+ return false;
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()
530
+ }
355
+ }
531
+}
356
+};
532
+
357
+
533
+static void npcm7xx_mft_get_max_rpm(Object *obj, Visitor *v, const char *name,
358
+static void allwinner_a10_ccm_class_init(ObjectClass *klass, void *data)
534
+ void *opaque, Error **errp)
359
+{
535
+{
360
+ DeviceClass *dc = DEVICE_CLASS(klass);
536
+ visit_type_uint32(v, name, (uint32_t *)opaque, errp);
537
+}
538
+
539
+static void npcm7xx_mft_set_max_rpm(Object *obj, Visitor *v, const char *name,
540
+ void *opaque, Error **errp)
541
+{
542
+ NPCM7xxMFTState *s = NPCM7XX_MFT(obj);
543
+ uint32_t *max_rpm = opaque;
544
+ uint32_t value;
545
+
546
+ if (!visit_type_uint32(v, name, &value, errp)) {
547
+ return;
548
+ }
549
+
550
+ *max_rpm = value;
551
+ npcm7xx_mft_capture(s);
552
+}
553
+
554
+static void npcm7xx_mft_duty_handler(void *opaque, int n, int value)
555
+{
556
+ NPCM7xxMFTState *s = NPCM7XX_MFT(opaque);
557
+
558
+ trace_npcm7xx_mft_set_duty(DEVICE(s)->canonical_path, n, value);
559
+ s->duty[n] = value;
560
+ npcm7xx_mft_capture(s);
561
+}
562
+
563
+static const struct MemoryRegionOps npcm7xx_mft_ops = {
564
+ .read = npcm7xx_mft_read,
565
+ .write = npcm7xx_mft_write,
566
+ .endianness = DEVICE_LITTLE_ENDIAN,
567
+ .valid = {
568
+ .min_access_size = 1,
569
+ .max_access_size = 2,
570
+ .unaligned = false,
571
+ .accepts = npcm7xx_mft_check_mem_op,
572
+ },
573
+};
574
+
575
+static void npcm7xx_mft_enter_reset(Object *obj, ResetType type)
576
+{
577
+ NPCM7xxMFTState *s = NPCM7XX_MFT(obj);
578
+
579
+ npcm7xx_mft_reset(s);
580
+}
581
+
582
+static void npcm7xx_mft_hold_reset(Object *obj)
583
+{
584
+ NPCM7xxMFTState *s = NPCM7XX_MFT(obj);
585
+
586
+ qemu_irq_lower(s->irq);
587
+}
588
+
589
+static void npcm7xx_mft_init(Object *obj)
590
+{
591
+ NPCM7xxMFTState *s = NPCM7XX_MFT(obj);
592
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
593
+ DeviceState *dev = DEVICE(obj);
594
+
595
+ memory_region_init_io(&s->iomem, obj, &npcm7xx_mft_ops, s,
596
+ TYPE_NPCM7XX_MFT, 4 * KiB);
597
+ sysbus_init_mmio(sbd, &s->iomem);
598
+ sysbus_init_irq(sbd, &s->irq);
599
+ s->clock_in = qdev_init_clock_in(dev, "clock-in", npcm7xx_mft_update_clock,
600
+ s, ClockUpdate);
601
+ s->clock_1 = qdev_init_clock_out(dev, "clock1");
602
+ s->clock_2 = qdev_init_clock_out(dev, "clock2");
603
+
604
+ for (int i = 0; i < NPCM7XX_PWM_PER_MODULE; ++i) {
605
+ object_property_add(obj, "max_rpm[*]", "uint32",
606
+ npcm7xx_mft_get_max_rpm,
607
+ npcm7xx_mft_set_max_rpm,
608
+ NULL, &s->max_rpm[i]);
609
+ }
610
+ qdev_init_gpio_in_named(dev, npcm7xx_mft_duty_handler, "duty",
611
+ NPCM7XX_MFT_FANIN_COUNT);
612
+}
613
+
614
+static const VMStateDescription vmstate_npcm7xx_mft = {
615
+ .name = "npcm7xx-mft-module",
616
+ .version_id = 0,
617
+ .minimum_version_id = 0,
618
+ .fields = (VMStateField[]) {
619
+ VMSTATE_CLOCK(clock_in, NPCM7xxMFTState),
620
+ VMSTATE_CLOCK(clock_1, NPCM7xxMFTState),
621
+ VMSTATE_CLOCK(clock_2, NPCM7xxMFTState),
622
+ VMSTATE_UINT16_ARRAY(regs, NPCM7xxMFTState, NPCM7XX_MFT_NR_REGS),
623
+ VMSTATE_UINT32_ARRAY(max_rpm, NPCM7xxMFTState, NPCM7XX_MFT_FANIN_COUNT),
624
+ VMSTATE_UINT32_ARRAY(duty, NPCM7xxMFTState, NPCM7XX_MFT_FANIN_COUNT),
625
+ VMSTATE_END_OF_LIST(),
626
+ },
627
+};
628
+
629
+static void npcm7xx_mft_class_init(ObjectClass *klass, void *data)
630
+{
631
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
361
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
632
+ DeviceClass *dc = DEVICE_CLASS(klass);
362
+
633
+
363
+ rc->phases.enter = allwinner_a10_ccm_reset_enter;
634
+ dc->desc = "NPCM7xx MFT Controller";
364
+ dc->vmsd = &allwinner_a10_ccm_vmstate;
635
+ dc->vmsd = &vmstate_npcm7xx_mft;
365
+}
636
+ rc->phases.enter = npcm7xx_mft_enter_reset;
366
+
637
+ rc->phases.hold = npcm7xx_mft_hold_reset;
367
+static const TypeInfo allwinner_a10_ccm_info = {
638
+}
368
+ .name = TYPE_AW_A10_CCM,
639
+
369
+ .parent = TYPE_SYS_BUS_DEVICE,
640
+static const TypeInfo npcm7xx_mft_info = {
370
+ .instance_init = allwinner_a10_ccm_init,
641
+ .name = TYPE_NPCM7XX_MFT,
371
+ .instance_size = sizeof(AwA10ClockCtlState),
642
+ .parent = TYPE_SYS_BUS_DEVICE,
372
+ .class_init = allwinner_a10_ccm_class_init,
643
+ .instance_size = sizeof(NPCM7xxMFTState),
373
+};
644
+ .class_init = npcm7xx_mft_class_init,
374
+
645
+ .instance_init = npcm7xx_mft_init,
375
+static void allwinner_a10_ccm_register(void)
646
+};
376
+{
647
+
377
+ type_register_static(&allwinner_a10_ccm_info);
648
+static void npcm7xx_mft_register_type(void)
378
+}
649
+{
379
+
650
+ type_register_static(&npcm7xx_mft_info);
380
+type_init(allwinner_a10_ccm_register)
651
+}
381
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
652
+type_init(npcm7xx_mft_register_type);
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
653
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
405
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
654
index XXXXXXX..XXXXXXX 100644
406
index XXXXXXX..XXXXXXX 100644
655
--- a/hw/misc/meson.build
407
--- a/hw/misc/meson.build
656
+++ b/hw/misc/meson.build
408
+++ b/hw/misc/meson.build
657
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_MAINSTONE', if_true: files('mst_fpga.c'))
409
@@ -XXX,XX +XXX,XX @@ subdir('macio')
658
softmmu_ss.add(when: 'CONFIG_NPCM7XX', if_true: files(
410
659
'npcm7xx_clk.c',
411
softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c'))
660
'npcm7xx_gcr.c',
412
661
+ 'npcm7xx_mft.c',
413
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c'))
662
'npcm7xx_pwm.c',
414
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
663
'npcm7xx_rng.c',
415
specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'))
664
))
416
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
665
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
666
index XXXXXXX..XXXXXXX 100644
667
--- a/hw/misc/trace-events
668
+++ b/hw/misc/trace-events
669
@@ -XXX,XX +XXX,XX @@ npcm7xx_clk_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " valu
670
npcm7xx_gcr_read(uint64_t offset, uint32_t value) " offset: 0x%04" PRIx64 " value: 0x%08" PRIx32
671
npcm7xx_gcr_write(uint64_t offset, uint32_t value) "offset: 0x%04" PRIx64 " value: 0x%08" PRIx32
672
673
+# npcm7xx_mft.c
674
+npcm7xx_mft_read(const char *name, uint64_t offset, uint16_t value) "%s: offset: 0x%04" PRIx64 " value: 0x%04" PRIx16
675
+npcm7xx_mft_write(const char *name, uint64_t offset, uint16_t value) "%s: offset: 0x%04" PRIx64 " value: 0x%04" PRIx16
676
+npcm7xx_mft_rpm(const char *clock, uint32_t clock_hz, int state, int32_t cnt, uint32_t rpm, uint32_t duty) " fan clk: %s clock_hz: %" PRIu32 ", state: %d, cnt: %" PRIi32 ", rpm: %" PRIu32 ", duty: %" PRIu32
677
+npcm7xx_mft_capture(const char *name, int irq_level) "%s: level: %d"
678
+npcm7xx_mft_update_clock(const char *name, uint16_t sel, uint64_t clock_period, uint64_t prescaled_clock_period) "%s: sel: 0x%02" PRIx16 ", period: %" PRIu64 ", prescaled: %" PRIu64
679
+npcm7xx_mft_set_duty(const char *name, int n, int value) "%s[%d]: %d"
680
+
681
# npcm7xx_rng.c
682
npcm7xx_rng_read(uint64_t offset, uint64_t value, unsigned size) "offset: 0x%04" PRIx64 " value: 0x%02" PRIx64 " size: %u"
683
npcm7xx_rng_write(uint64_t offset, uint64_t value, unsigned size) "offset: 0x%04" PRIx64 " value: 0x%02" PRIx64 " size: %u"
684
--
417
--
685
2.20.1
418
2.34.1
686
687
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
Add a model of the Xilinx Versal Accelerator RAM (XRAM).
3
During SPL boot several DRAM Controller registers are used. Most
4
This is mainly a stub to make firmware happy. The size of
4
important registers are those related to DRAM initialization and
5
the RAMs can be probed. The interrupt mask logic is
5
calibration, where SPL initiates process and waits until certain bit is
6
modelled but none of the interrups will ever be raised
6
set/cleared.
7
unless injected.
7
8
8
This patch adds these registers, initializes reset values from user's
9
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
9
guide and updates state of registers as SPL expects it.
10
Message-id: 20210308224637.2949533-2-edgar.iglesias@gmail.com
10
11
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
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
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
16
---
14
include/hw/misc/xlnx-versal-xramc.h | 97 +++++++++++
17
include/hw/arm/allwinner-a10.h | 2 +
15
hw/misc/xlnx-versal-xramc.c | 253 ++++++++++++++++++++++++++++
18
include/hw/misc/allwinner-a10-dramc.h | 68 ++++++++++
16
hw/misc/meson.build | 1 +
19
hw/arm/allwinner-a10.c | 7 +
17
3 files changed, 351 insertions(+)
20
hw/misc/allwinner-a10-dramc.c | 179 ++++++++++++++++++++++++++
18
create mode 100644 include/hw/misc/xlnx-versal-xramc.h
21
hw/arm/Kconfig | 1 +
19
create mode 100644 hw/misc/xlnx-versal-xramc.c
22
hw/misc/Kconfig | 3 +
20
23
hw/misc/meson.build | 1 +
21
diff --git a/include/hw/misc/xlnx-versal-xramc.h b/include/hw/misc/xlnx-versal-xramc.h
24
7 files changed, 261 insertions(+)
25
create mode 100644 include/hw/misc/allwinner-a10-dramc.h
26
create mode 100644 hw/misc/allwinner-a10-dramc.c
27
28
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
29
index XXXXXXX..XXXXXXX 100644
30
--- a/include/hw/arm/allwinner-a10.h
31
+++ b/include/hw/arm/allwinner-a10.h
32
@@ -XXX,XX +XXX,XX @@
33
#include "hw/usb/hcd-ehci.h"
34
#include "hw/rtc/allwinner-rtc.h"
35
#include "hw/misc/allwinner-a10-ccm.h"
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
22
new file mode 100644
49
new file mode 100644
23
index XXXXXXX..XXXXXXX
50
index XXXXXXX..XXXXXXX
24
--- /dev/null
51
--- /dev/null
25
+++ b/include/hw/misc/xlnx-versal-xramc.h
52
+++ b/include/hw/misc/allwinner-a10-dramc.h
26
@@ -XXX,XX +XXX,XX @@
53
@@ -XXX,XX +XXX,XX @@
27
+/*
54
+/*
28
+ * QEMU model of the Xilinx XRAM Controller.
55
+ * Allwinner A10 DRAM Controller emulation
29
+ *
56
+ *
30
+ * Copyright (c) 2021 Xilinx Inc.
57
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
31
+ * SPDX-License-Identifier: GPL-2.0-or-later
58
+ *
32
+ * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com>
59
+ * This file is derived from Allwinner H3 DRAMC,
33
+ */
60
+ * by Niek Linnenbank.
34
+
61
+ *
35
+#ifndef XLNX_VERSAL_XRAMC_H
62
+ * This program is free software: you can redistribute it and/or modify
36
+#define XLNX_VERSAL_XRAMC_H
63
+ * it under the terms of the GNU General Public License as published by
37
+
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"
38
+#include "hw/sysbus.h"
80
+#include "hw/sysbus.h"
39
+#include "hw/register.h"
81
+#include "hw/register.h"
40
+
82
+
41
+#define TYPE_XLNX_XRAM_CTRL "xlnx.versal-xramc"
83
+/**
42
+
84
+ * @name Constants
43
+#define XLNX_XRAM_CTRL(obj) \
85
+ * @{
44
+ OBJECT_CHECK(XlnxXramCtrl, (obj), TYPE_XLNX_XRAM_CTRL)
86
+ */
45
+
87
+
46
+REG32(XRAM_ERR_CTRL, 0x0)
88
+/** Size of register I/O address space used by DRAMC device */
47
+ FIELD(XRAM_ERR_CTRL, UE_RES, 3, 1)
89
+#define AW_A10_DRAMC_IOSIZE (0x1000)
48
+ FIELD(XRAM_ERR_CTRL, PWR_ERR_RES, 2, 1)
90
+
49
+ FIELD(XRAM_ERR_CTRL, PZ_ERR_RES, 1, 1)
91
+/** Total number of known registers */
50
+ FIELD(XRAM_ERR_CTRL, APB_ERR_RES, 0, 1)
92
+#define AW_A10_DRAMC_REGS_NUM (AW_A10_DRAMC_IOSIZE / sizeof(uint32_t))
51
+REG32(XRAM_ISR, 0x4)
93
+
52
+ FIELD(XRAM_ISR, INV_APB, 0, 1)
94
+/** @} */
53
+REG32(XRAM_IMR, 0x8)
95
+
54
+ FIELD(XRAM_IMR, INV_APB, 0, 1)
96
+/**
55
+REG32(XRAM_IEN, 0xc)
97
+ * @name Object model
56
+ FIELD(XRAM_IEN, INV_APB, 0, 1)
98
+ * @{
57
+REG32(XRAM_IDS, 0x10)
99
+ */
58
+ FIELD(XRAM_IDS, INV_APB, 0, 1)
100
+
59
+REG32(XRAM_ECC_CNTL, 0x14)
101
+#define TYPE_AW_A10_DRAMC "allwinner-a10-dramc"
60
+ FIELD(XRAM_ECC_CNTL, FI_MODE, 2, 1)
102
+OBJECT_DECLARE_SIMPLE_TYPE(AwA10DramControllerState, AW_A10_DRAMC)
61
+ FIELD(XRAM_ECC_CNTL, DET_ONLY, 1, 1)
103
+
62
+ FIELD(XRAM_ECC_CNTL, ECC_ON_OFF, 0, 1)
104
+/** @} */
63
+REG32(XRAM_CLR_EXE, 0x18)
105
+
64
+ FIELD(XRAM_CLR_EXE, MON_7, 7, 1)
106
+/**
65
+ FIELD(XRAM_CLR_EXE, MON_6, 6, 1)
107
+ * Allwinner A10 DRAMC object instance state.
66
+ FIELD(XRAM_CLR_EXE, MON_5, 5, 1)
108
+ */
67
+ FIELD(XRAM_CLR_EXE, MON_4, 4, 1)
109
+struct AwA10DramControllerState {
68
+ FIELD(XRAM_CLR_EXE, MON_3, 3, 1)
110
+ /*< private >*/
69
+ FIELD(XRAM_CLR_EXE, MON_2, 2, 1)
70
+ FIELD(XRAM_CLR_EXE, MON_1, 1, 1)
71
+ FIELD(XRAM_CLR_EXE, MON_0, 0, 1)
72
+REG32(XRAM_CE_FFA, 0x1c)
73
+ FIELD(XRAM_CE_FFA, ADDR, 0, 20)
74
+REG32(XRAM_CE_FFD0, 0x20)
75
+REG32(XRAM_CE_FFD1, 0x24)
76
+REG32(XRAM_CE_FFD2, 0x28)
77
+REG32(XRAM_CE_FFD3, 0x2c)
78
+REG32(XRAM_CE_FFE, 0x30)
79
+ FIELD(XRAM_CE_FFE, SYNDROME, 0, 16)
80
+REG32(XRAM_UE_FFA, 0x34)
81
+ FIELD(XRAM_UE_FFA, ADDR, 0, 20)
82
+REG32(XRAM_UE_FFD0, 0x38)
83
+REG32(XRAM_UE_FFD1, 0x3c)
84
+REG32(XRAM_UE_FFD2, 0x40)
85
+REG32(XRAM_UE_FFD3, 0x44)
86
+REG32(XRAM_UE_FFE, 0x48)
87
+ FIELD(XRAM_UE_FFE, SYNDROME, 0, 16)
88
+REG32(XRAM_FI_D0, 0x4c)
89
+REG32(XRAM_FI_D1, 0x50)
90
+REG32(XRAM_FI_D2, 0x54)
91
+REG32(XRAM_FI_D3, 0x58)
92
+REG32(XRAM_FI_SY, 0x5c)
93
+ FIELD(XRAM_FI_SY, DATA, 0, 16)
94
+REG32(XRAM_RMW_UE_FFA, 0x70)
95
+ FIELD(XRAM_RMW_UE_FFA, ADDR, 0, 20)
96
+REG32(XRAM_FI_CNTR, 0x74)
97
+ FIELD(XRAM_FI_CNTR, COUNT, 0, 24)
98
+REG32(XRAM_IMP, 0x80)
99
+ FIELD(XRAM_IMP, SIZE, 0, 4)
100
+REG32(XRAM_PRDY_DBG, 0x84)
101
+ FIELD(XRAM_PRDY_DBG, ISLAND3, 12, 4)
102
+ FIELD(XRAM_PRDY_DBG, ISLAND2, 8, 4)
103
+ FIELD(XRAM_PRDY_DBG, ISLAND1, 4, 4)
104
+ FIELD(XRAM_PRDY_DBG, ISLAND0, 0, 4)
105
+REG32(XRAM_SAFETY_CHK, 0xff8)
106
+
107
+#define XRAM_CTRL_R_MAX (R_XRAM_SAFETY_CHK + 1)
108
+
109
+typedef struct XlnxXramCtrl {
110
+ SysBusDevice parent_obj;
111
+ SysBusDevice parent_obj;
111
+ MemoryRegion ram;
112
+ /*< public >*/
112
+ qemu_irq irq;
113
+
113
+
114
+ /** Maps I/O registers in physical memory */
114
+ struct {
115
+ MemoryRegion iomem;
115
+ uint64_t size;
116
+
116
+ unsigned int encoded_size;
117
+ /** Array of hardware registers */
117
+ } cfg;
118
+ uint32_t regs[AW_A10_DRAMC_REGS_NUM];
118
+
119
+};
119
+ RegisterInfoArray *reg_array;
120
+
120
+ uint32_t regs[XRAM_CTRL_R_MAX];
121
+#endif /* HW_MISC_ALLWINNER_A10_DRAMC_H */
121
+ RegisterInfo regs_info[XRAM_CTRL_R_MAX];
122
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
122
+} XlnxXramCtrl;
123
index XXXXXXX..XXXXXXX 100644
123
+#endif
124
--- a/hw/arm/allwinner-a10.c
124
diff --git a/hw/misc/xlnx-versal-xramc.c b/hw/misc/xlnx-versal-xramc.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
125
new file mode 100644
155
new file mode 100644
126
index XXXXXXX..XXXXXXX
156
index XXXXXXX..XXXXXXX
127
--- /dev/null
157
--- /dev/null
128
+++ b/hw/misc/xlnx-versal-xramc.c
158
+++ b/hw/misc/allwinner-a10-dramc.c
129
@@ -XXX,XX +XXX,XX @@
159
@@ -XXX,XX +XXX,XX @@
130
+/*
160
+/*
131
+ * QEMU model of the Xilinx XRAM Controller.
161
+ * Allwinner A10 DRAM Controller emulation
132
+ *
162
+ *
133
+ * Copyright (c) 2021 Xilinx Inc.
163
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
134
+ * SPDX-License-Identifier: GPL-2.0-or-later
164
+ *
135
+ * Written by Edgar E. Iglesias <edgar.iglesias@xilinx.com>
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/>.
136
+ */
180
+ */
137
+
181
+
138
+#include "qemu/osdep.h"
182
+#include "qemu/osdep.h"
139
+#include "qemu/units.h"
183
+#include "qemu/units.h"
140
+#include "qapi/error.h"
184
+#include "hw/sysbus.h"
141
+#include "migration/vmstate.h"
185
+#include "migration/vmstate.h"
142
+#include "hw/sysbus.h"
186
+#include "qemu/log.h"
143
+#include "hw/register.h"
187
+#include "qemu/module.h"
144
+#include "hw/qdev-properties.h"
188
+#include "hw/misc/allwinner-a10-dramc.h"
145
+#include "hw/irq.h"
189
+
146
+#include "hw/misc/xlnx-versal-xramc.h"
190
+/* DRAMC register offsets */
147
+
191
+enum {
148
+#ifndef XLNX_XRAM_CTRL_ERR_DEBUG
192
+ REG_SDR_CCR = 0x0000,
149
+#define XLNX_XRAM_CTRL_ERR_DEBUG 0
193
+ REG_SDR_ZQCR0 = 0x00a8,
150
+#endif
194
+ REG_SDR_ZQSR = 0x00b0
151
+
195
+};
152
+static void xram_update_irq(XlnxXramCtrl *s)
196
+
153
+{
197
+#define REG_INDEX(offset) (offset / sizeof(uint32_t))
154
+ bool pending = s->regs[R_XRAM_ISR] & ~s->regs[R_XRAM_IMR];
198
+
155
+ qemu_set_irq(s->irq, pending);
199
+/* DRAMC register flags */
156
+}
200
+enum {
157
+
201
+ REG_SDR_CCR_DATA_TRAINING = (1 << 30),
158
+static void xram_isr_postw(RegisterInfo *reg, uint64_t val64)
202
+ REG_SDR_CCR_DRAM_INIT = (1 << 31),
159
+{
203
+};
160
+ XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque);
204
+enum {
161
+ xram_update_irq(s);
205
+ REG_SDR_ZQSR_ZCAL = (1 << 31),
162
+}
206
+};
163
+
207
+
164
+static uint64_t xram_ien_prew(RegisterInfo *reg, uint64_t val64)
208
+/* DRAMC register reset values */
165
+{
209
+enum {
166
+ XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque);
210
+ REG_SDR_CCR_RESET = 0x80020000,
167
+ uint32_t val = val64;
211
+ REG_SDR_ZQCR0_RESET = 0x07b00000,
168
+
212
+ REG_SDR_ZQSR_RESET = 0x80000000
169
+ s->regs[R_XRAM_IMR] &= ~val;
213
+};
170
+ xram_update_irq(s);
214
+
171
+ return 0;
215
+static uint64_t allwinner_a10_dramc_read(void *opaque, hwaddr offset,
172
+}
216
+ unsigned size)
173
+
217
+{
174
+static uint64_t xram_ids_prew(RegisterInfo *reg, uint64_t val64)
218
+ const AwA10DramControllerState *s = AW_A10_DRAMC(opaque);
175
+{
219
+ const uint32_t idx = REG_INDEX(offset);
176
+ XlnxXramCtrl *s = XLNX_XRAM_CTRL(reg->opaque);
220
+
177
+ uint32_t val = val64;
221
+ switch (offset) {
178
+
222
+ case REG_SDR_CCR:
179
+ s->regs[R_XRAM_IMR] |= val;
223
+ case REG_SDR_ZQCR0:
180
+ xram_update_irq(s);
224
+ case REG_SDR_ZQSR:
181
+ return 0;
225
+ break;
182
+}
226
+ case 0x2e4 ... AW_A10_DRAMC_IOSIZE:
183
+
227
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: out-of-bounds offset 0x%04x\n",
184
+static const RegisterAccessInfo xram_ctrl_regs_info[] = {
228
+ __func__, (uint32_t)offset);
185
+ { .name = "XRAM_ERR_CTRL", .addr = A_XRAM_ERR_CTRL,
229
+ return 0;
186
+ .reset = 0xf,
230
+ default:
187
+ .rsvd = 0xfffffff0,
231
+ qemu_log_mask(LOG_UNIMP, "%s: unimplemented read offset 0x%04x\n",
188
+ },{ .name = "XRAM_ISR", .addr = A_XRAM_ISR,
232
+ __func__, (uint32_t)offset);
189
+ .rsvd = 0xfffff800,
233
+ return 0;
190
+ .w1c = 0x7ff,
191
+ .post_write = xram_isr_postw,
192
+ },{ .name = "XRAM_IMR", .addr = A_XRAM_IMR,
193
+ .reset = 0x7ff,
194
+ .rsvd = 0xfffff800,
195
+ .ro = 0x7ff,
196
+ },{ .name = "XRAM_IEN", .addr = A_XRAM_IEN,
197
+ .rsvd = 0xfffff800,
198
+ .pre_write = xram_ien_prew,
199
+ },{ .name = "XRAM_IDS", .addr = A_XRAM_IDS,
200
+ .rsvd = 0xfffff800,
201
+ .pre_write = xram_ids_prew,
202
+ },{ .name = "XRAM_ECC_CNTL", .addr = A_XRAM_ECC_CNTL,
203
+ .rsvd = 0xfffffff8,
204
+ },{ .name = "XRAM_CLR_EXE", .addr = A_XRAM_CLR_EXE,
205
+ .rsvd = 0xffffff00,
206
+ },{ .name = "XRAM_CE_FFA", .addr = A_XRAM_CE_FFA,
207
+ .rsvd = 0xfff00000,
208
+ .ro = 0xfffff,
209
+ },{ .name = "XRAM_CE_FFD0", .addr = A_XRAM_CE_FFD0,
210
+ .ro = 0xffffffff,
211
+ },{ .name = "XRAM_CE_FFD1", .addr = A_XRAM_CE_FFD1,
212
+ .ro = 0xffffffff,
213
+ },{ .name = "XRAM_CE_FFD2", .addr = A_XRAM_CE_FFD2,
214
+ .ro = 0xffffffff,
215
+ },{ .name = "XRAM_CE_FFD3", .addr = A_XRAM_CE_FFD3,
216
+ .ro = 0xffffffff,
217
+ },{ .name = "XRAM_CE_FFE", .addr = A_XRAM_CE_FFE,
218
+ .rsvd = 0xffff0000,
219
+ .ro = 0xffff,
220
+ },{ .name = "XRAM_UE_FFA", .addr = A_XRAM_UE_FFA,
221
+ .rsvd = 0xfff00000,
222
+ .ro = 0xfffff,
223
+ },{ .name = "XRAM_UE_FFD0", .addr = A_XRAM_UE_FFD0,
224
+ .ro = 0xffffffff,
225
+ },{ .name = "XRAM_UE_FFD1", .addr = A_XRAM_UE_FFD1,
226
+ .ro = 0xffffffff,
227
+ },{ .name = "XRAM_UE_FFD2", .addr = A_XRAM_UE_FFD2,
228
+ .ro = 0xffffffff,
229
+ },{ .name = "XRAM_UE_FFD3", .addr = A_XRAM_UE_FFD3,
230
+ .ro = 0xffffffff,
231
+ },{ .name = "XRAM_UE_FFE", .addr = A_XRAM_UE_FFE,
232
+ .rsvd = 0xffff0000,
233
+ .ro = 0xffff,
234
+ },{ .name = "XRAM_FI_D0", .addr = A_XRAM_FI_D0,
235
+ },{ .name = "XRAM_FI_D1", .addr = A_XRAM_FI_D1,
236
+ },{ .name = "XRAM_FI_D2", .addr = A_XRAM_FI_D2,
237
+ },{ .name = "XRAM_FI_D3", .addr = A_XRAM_FI_D3,
238
+ },{ .name = "XRAM_FI_SY", .addr = A_XRAM_FI_SY,
239
+ .rsvd = 0xffff0000,
240
+ },{ .name = "XRAM_RMW_UE_FFA", .addr = A_XRAM_RMW_UE_FFA,
241
+ .rsvd = 0xfff00000,
242
+ .ro = 0xfffff,
243
+ },{ .name = "XRAM_FI_CNTR", .addr = A_XRAM_FI_CNTR,
244
+ .rsvd = 0xff000000,
245
+ },{ .name = "XRAM_IMP", .addr = A_XRAM_IMP,
246
+ .reset = 0x4,
247
+ .rsvd = 0xfffffff0,
248
+ .ro = 0xf,
249
+ },{ .name = "XRAM_PRDY_DBG", .addr = A_XRAM_PRDY_DBG,
250
+ .reset = 0xffff,
251
+ .rsvd = 0xffff0000,
252
+ .ro = 0xffff,
253
+ },{ .name = "XRAM_SAFETY_CHK", .addr = A_XRAM_SAFETY_CHK,
254
+ }
234
+ }
255
+};
235
+
256
+
236
+ return s->regs[idx];
257
+static void xram_ctrl_reset_enter(Object *obj, ResetType type)
237
+}
258
+{
238
+
259
+ XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj);
239
+static void allwinner_a10_dramc_write(void *opaque, hwaddr offset,
260
+ unsigned int i;
240
+ uint64_t val, unsigned size)
261
+
241
+{
262
+ for (i = 0; i < ARRAY_SIZE(s->regs_info); ++i) {
242
+ AwA10DramControllerState *s = AW_A10_DRAMC(opaque);
263
+ register_reset(&s->regs_info[i]);
243
+ const uint32_t idx = REG_INDEX(offset);
244
+
245
+ switch (offset) {
246
+ case REG_SDR_CCR:
247
+ if (val & REG_SDR_CCR_DRAM_INIT) {
248
+ /* Clear DRAM_INIT to indicate process is done. */
249
+ val &= ~REG_SDR_CCR_DRAM_INIT;
250
+ }
251
+ if (val & REG_SDR_CCR_DATA_TRAINING) {
252
+ /* Clear DATA_TRAINING to indicate process is done. */
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;
264
+ }
268
+ }
265
+
269
+
266
+ ARRAY_FIELD_DP32(s->regs, XRAM_IMP, SIZE, s->cfg.encoded_size);
270
+ s->regs[idx] = (uint32_t) val;
267
+}
271
+}
268
+
272
+
269
+static void xram_ctrl_reset_hold(Object *obj)
273
+static const MemoryRegionOps allwinner_a10_dramc_ops = {
270
+{
274
+ .read = allwinner_a10_dramc_read,
271
+ XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj);
275
+ .write = allwinner_a10_dramc_write,
272
+
276
+ .endianness = DEVICE_NATIVE_ENDIAN,
273
+ xram_update_irq(s);
274
+}
275
+
276
+static const MemoryRegionOps xram_ctrl_ops = {
277
+ .read = register_read_memory,
278
+ .write = register_write_memory,
279
+ .endianness = DEVICE_LITTLE_ENDIAN,
280
+ .valid = {
277
+ .valid = {
281
+ .min_access_size = 4,
278
+ .min_access_size = 4,
282
+ .max_access_size = 4,
279
+ .max_access_size = 4,
283
+ },
280
+ },
284
+};
281
+ .impl.min_access_size = 4,
285
+
282
+};
286
+static void xram_ctrl_realize(DeviceState *dev, Error **errp)
283
+
287
+{
284
+static void allwinner_a10_dramc_reset_enter(Object *obj, ResetType type)
288
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
285
+{
289
+ XlnxXramCtrl *s = XLNX_XRAM_CTRL(dev);
286
+ AwA10DramControllerState *s = AW_A10_DRAMC(obj);
290
+
287
+
291
+ switch (s->cfg.size) {
288
+ /* Set default values for registers */
292
+ case 64 * KiB:
289
+ s->regs[REG_INDEX(REG_SDR_CCR)] = REG_SDR_CCR_RESET;
293
+ s->cfg.encoded_size = 0;
290
+ s->regs[REG_INDEX(REG_SDR_ZQCR0)] = REG_SDR_ZQCR0_RESET;
294
+ break;
291
+ s->regs[REG_INDEX(REG_SDR_ZQSR)] = REG_SDR_ZQSR_RESET;
295
+ case 128 * KiB:
292
+}
296
+ s->cfg.encoded_size = 1;
293
+
297
+ break;
294
+static void allwinner_a10_dramc_init(Object *obj)
298
+ case 256 * KiB:
295
+{
299
+ s->cfg.encoded_size = 2;
300
+ break;
301
+ case 512 * KiB:
302
+ s->cfg.encoded_size = 3;
303
+ break;
304
+ case 1 * MiB:
305
+ s->cfg.encoded_size = 4;
306
+ break;
307
+ default:
308
+ error_setg(errp, "Unsupported XRAM size %" PRId64, s->cfg.size);
309
+ return;
310
+ }
311
+
312
+ memory_region_init_ram(&s->ram, OBJECT(s),
313
+ object_get_canonical_path_component(OBJECT(s)),
314
+ s->cfg.size, &error_fatal);
315
+ sysbus_init_mmio(sbd, &s->ram);
316
+}
317
+
318
+static void xram_ctrl_init(Object *obj)
319
+{
320
+ XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj);
321
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
296
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
322
+
297
+ AwA10DramControllerState *s = AW_A10_DRAMC(obj);
323
+ s->reg_array =
298
+
324
+ register_init_block32(DEVICE(obj), xram_ctrl_regs_info,
299
+ /* Memory mapping */
325
+ ARRAY_SIZE(xram_ctrl_regs_info),
300
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_a10_dramc_ops, s,
326
+ s->regs_info, s->regs,
301
+ TYPE_AW_A10_DRAMC, AW_A10_DRAMC_IOSIZE);
327
+ &xram_ctrl_ops,
302
+ sysbus_init_mmio(sbd, &s->iomem);
328
+ XLNX_XRAM_CTRL_ERR_DEBUG,
303
+}
329
+ XRAM_CTRL_R_MAX * 4);
304
+
330
+ sysbus_init_mmio(sbd, &s->reg_array->mem);
305
+static const VMStateDescription allwinner_a10_dramc_vmstate = {
331
+ sysbus_init_irq(sbd, &s->irq);
306
+ .name = "allwinner-a10-dramc",
332
+}
333
+
334
+static void xram_ctrl_finalize(Object *obj)
335
+{
336
+ XlnxXramCtrl *s = XLNX_XRAM_CTRL(obj);
337
+ register_finalize_block(s->reg_array);
338
+}
339
+
340
+static const VMStateDescription vmstate_xram_ctrl = {
341
+ .name = TYPE_XLNX_XRAM_CTRL,
342
+ .version_id = 1,
307
+ .version_id = 1,
343
+ .minimum_version_id = 1,
308
+ .minimum_version_id = 1,
344
+ .fields = (VMStateField[]) {
309
+ .fields = (VMStateField[]) {
345
+ VMSTATE_UINT32_ARRAY(regs, XlnxXramCtrl, XRAM_CTRL_R_MAX),
310
+ VMSTATE_UINT32_ARRAY(regs, AwA10DramControllerState,
346
+ VMSTATE_END_OF_LIST(),
311
+ AW_A10_DRAMC_REGS_NUM),
312
+ VMSTATE_END_OF_LIST()
347
+ }
313
+ }
348
+};
314
+};
349
+
315
+
350
+static Property xram_ctrl_properties[] = {
316
+static void allwinner_a10_dramc_class_init(ObjectClass *klass, void *data)
351
+ DEFINE_PROP_UINT64("size", XlnxXramCtrl, cfg.size, 1 * MiB),
317
+{
352
+ DEFINE_PROP_END_OF_LIST(),
318
+ DeviceClass *dc = DEVICE_CLASS(klass);
353
+};
354
+
355
+static void xram_ctrl_class_init(ObjectClass *klass, void *data)
356
+{
357
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
319
+ ResettableClass *rc = RESETTABLE_CLASS(klass);
358
+ DeviceClass *dc = DEVICE_CLASS(klass);
320
+
359
+
321
+ rc->phases.enter = allwinner_a10_dramc_reset_enter;
360
+ dc->realize = xram_ctrl_realize;
322
+ dc->vmsd = &allwinner_a10_dramc_vmstate;
361
+ dc->vmsd = &vmstate_xram_ctrl;
323
+}
362
+ device_class_set_props(dc, xram_ctrl_properties);
324
+
363
+
325
+static const TypeInfo allwinner_a10_dramc_info = {
364
+ rc->phases.enter = xram_ctrl_reset_enter;
326
+ .name = TYPE_AW_A10_DRAMC,
365
+ rc->phases.hold = xram_ctrl_reset_hold;
327
+ .parent = TYPE_SYS_BUS_DEVICE,
366
+}
328
+ .instance_init = allwinner_a10_dramc_init,
367
+
329
+ .instance_size = sizeof(AwA10DramControllerState),
368
+static const TypeInfo xram_ctrl_info = {
330
+ .class_init = allwinner_a10_dramc_class_init,
369
+ .name = TYPE_XLNX_XRAM_CTRL,
331
+};
370
+ .parent = TYPE_SYS_BUS_DEVICE,
332
+
371
+ .instance_size = sizeof(XlnxXramCtrl),
333
+static void allwinner_a10_dramc_register(void)
372
+ .class_init = xram_ctrl_class_init,
334
+{
373
+ .instance_init = xram_ctrl_init,
335
+ type_register_static(&allwinner_a10_dramc_info);
374
+ .instance_finalize = xram_ctrl_finalize,
336
+}
375
+};
337
+
376
+
338
+type_init(allwinner_a10_dramc_register)
377
+static void xram_ctrl_register_types(void)
339
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
378
+{
340
index XXXXXXX..XXXXXXX 100644
379
+ type_register_static(&xram_ctrl_info);
341
--- a/hw/arm/Kconfig
380
+}
342
+++ b/hw/arm/Kconfig
381
+
343
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
382
+type_init(xram_ctrl_register_types)
344
select ALLWINNER_A10_PIT
345
select ALLWINNER_A10_PIC
346
select ALLWINNER_A10_CCM
347
+ select ALLWINNER_A10_DRAMC
348
select ALLWINNER_EMAC
349
select SERIAL
350
select UNIMP
351
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
352
index XXXXXXX..XXXXXXX 100644
353
--- a/hw/misc/Kconfig
354
+++ b/hw/misc/Kconfig
355
@@ -XXX,XX +XXX,XX @@ config LASI
356
config ALLWINNER_A10_CCM
357
bool
358
359
+config ALLWINNER_A10_DRAMC
360
+ bool
361
+
362
source macio/Kconfig
383
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
363
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
384
index XXXXXXX..XXXXXXX 100644
364
index XXXXXXX..XXXXXXX 100644
385
--- a/hw/misc/meson.build
365
--- a/hw/misc/meson.build
386
+++ b/hw/misc/meson.build
366
+++ b/hw/misc/meson.build
387
@@ -XXX,XX +XXX,XX @@ softmmu_ss.add(when: 'CONFIG_RASPI', if_true: files(
367
@@ -XXX,XX +XXX,XX @@ subdir('macio')
388
))
368
softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c'))
389
softmmu_ss.add(when: 'CONFIG_SLAVIO', if_true: files('slavio_misc.c'))
369
390
softmmu_ss.add(when: 'CONFIG_ZYNQ', if_true: files('zynq_slcr.c', 'zynq-xadc.c'))
370
softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c'))
391
+softmmu_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('xlnx-versal-xramc.c'))
371
+softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_DRAMC', if_true: files('allwinner-a10-dramc.c'))
392
softmmu_ss.add(when: 'CONFIG_STM32F2XX_SYSCFG', if_true: files('stm32f2xx_syscfg.c'))
372
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
393
softmmu_ss.add(when: 'CONFIG_STM32F4XX_SYSCFG', if_true: files('stm32f4xx_syscfg.c'))
373
specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'))
394
softmmu_ss.add(when: 'CONFIG_STM32F4XX_EXTI', if_true: files('stm32f4xx_exti.c'))
374
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
395
--
375
--
396
2.20.1
376
2.34.1
397
398
diff view generated by jsdifflib
1
The template header is now included only once; just inline its contents
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
in hw/display/pxa2xx_lcd.c.
3
2
3
This patch implements Allwinner TWI/I2C controller emulation. Only
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
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
6
Message-id: 20210211141515.8755-10-peter.maydell@linaro.org
7
---
19
---
8
hw/display/pxa2xx_template.h | 434 -----------------------------------
20
docs/system/arm/cubieboard.rst | 1 +
9
hw/display/pxa2xx_lcd.c | 427 +++++++++++++++++++++++++++++++++-
21
docs/system/arm/orangepi.rst | 1 +
10
2 files changed, 425 insertions(+), 436 deletions(-)
22
include/hw/arm/allwinner-a10.h | 2 +
11
delete mode 100644 hw/display/pxa2xx_template.h
23
include/hw/arm/allwinner-h3.h | 3 +
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/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h
36
diff --git a/docs/system/arm/cubieboard.rst b/docs/system/arm/cubieboard.rst
14
deleted file mode 100644
37
index XXXXXXX..XXXXXXX 100644
38
--- a/docs/system/arm/cubieboard.rst
39
+++ b/docs/system/arm/cubieboard.rst
40
@@ -XXX,XX +XXX,XX @@ Emulated devices:
41
- SDHCI
42
- USB controller
43
- SATA controller
44
+- TWI (I2C) controller
45
diff --git a/docs/system/arm/orangepi.rst b/docs/system/arm/orangepi.rst
46
index XXXXXXX..XXXXXXX 100644
47
--- a/docs/system/arm/orangepi.rst
48
+++ b/docs/system/arm/orangepi.rst
49
@@ -XXX,XX +XXX,XX @@ The Orange Pi PC machine supports the following devices:
50
* Clock Control Unit
51
* System Control module
52
* Security Identifier device
53
+ * TWI (I2C)
54
55
Limitations
56
"""""""""""
57
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
58
index XXXXXXX..XXXXXXX 100644
59
--- a/include/hw/arm/allwinner-a10.h
60
+++ b/include/hw/arm/allwinner-a10.h
61
@@ -XXX,XX +XXX,XX @@
62
#include "hw/rtc/allwinner-rtc.h"
63
#include "hw/misc/allwinner-a10-ccm.h"
64
#include "hw/misc/allwinner-a10-dramc.h"
65
+#include "hw/i2c/allwinner-i2c.h"
66
67
#include "target/arm/cpu.h"
68
#include "qom/object.h"
69
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
70
AwEmacState emac;
71
AllwinnerAHCIState sata;
72
AwSdHostState mmc0;
73
+ AWI2CState i2c0;
74
AwRtcState rtc;
75
MemoryRegion sram_a;
76
EHCISysBusState ehci[AW_A10_NUM_USB];
77
diff --git a/include/hw/arm/allwinner-h3.h b/include/hw/arm/allwinner-h3.h
78
index XXXXXXX..XXXXXXX 100644
79
--- a/include/hw/arm/allwinner-h3.h
80
+++ b/include/hw/arm/allwinner-h3.h
81
@@ -XXX,XX +XXX,XX @@
82
#include "hw/sd/allwinner-sdhost.h"
83
#include "hw/net/allwinner-sun8i-emac.h"
84
#include "hw/rtc/allwinner-rtc.h"
85
+#include "hw/i2c/allwinner-i2c.h"
86
#include "target/arm/cpu.h"
87
#include "sysemu/block-backend.h"
88
89
@@ -XXX,XX +XXX,XX @@ enum {
90
AW_H3_DEV_UART2,
91
AW_H3_DEV_UART3,
92
AW_H3_DEV_EMAC,
93
+ AW_H3_DEV_TWI0,
94
AW_H3_DEV_DRAMCOM,
95
AW_H3_DEV_DRAMCTL,
96
AW_H3_DEV_DRAMPHY,
97
@@ -XXX,XX +XXX,XX @@ struct AwH3State {
98
AwH3SysCtrlState sysctrl;
99
AwSidState sid;
100
AwSdHostState mmc0;
101
+ AWI2CState i2c0;
102
AwSun8iEmacState emac;
103
AwRtcState rtc;
104
GICState gic;
105
diff --git a/include/hw/i2c/allwinner-i2c.h b/include/hw/i2c/allwinner-i2c.h
106
new file mode 100644
15
index XXXXXXX..XXXXXXX
107
index XXXXXXX..XXXXXXX
16
--- a/hw/display/pxa2xx_template.h
108
--- /dev/null
17
+++ /dev/null
109
+++ b/include/hw/i2c/allwinner-i2c.h
18
@@ -XXX,XX +XXX,XX @@
110
@@ -XXX,XX +XXX,XX @@
19
-/*
111
+/*
20
- * Intel XScale PXA255/270 LCDC emulation.
112
+ * Allwinner I2C Bus Serial Interface registers definition
21
- *
113
+ *
22
- * Copyright (c) 2006 Openedhand Ltd.
114
+ * Copyright (C) 2022 Strahinja Jankovic. <strahinja.p.jankovic@gmail.com>
23
- * Written by Andrzej Zaborowski <balrog@zabor.org>
115
+ *
24
- *
116
+ * This file is derived from IMX I2C controller,
25
- * This code is licensed under the GPLv2.
117
+ * by Jean-Christophe DUBOIS .
26
- *
118
+ *
27
- * Framebuffer format conversion routines.
119
+ * This program is free software; you can redistribute it and/or modify it
28
- */
120
+ * under the terms of the GNU General Public License as published by the
29
-
121
+ * Free Software Foundation; either version 2 of the License, or
30
-# define SKIP_PIXEL(to) do { to += deststep; } while (0)
122
+ * (at your option) any later version.
31
-# define COPY_PIXEL(to, from) \
123
+ *
32
- do { \
124
+ * This program is distributed in the hope that it will be useful, but WITHOUT
33
- *(uint32_t *) to = from; \
125
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34
- SKIP_PIXEL(to); \
126
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
35
- } while (0)
127
+ * for more details.
36
-
128
+ *
37
-#ifdef HOST_WORDS_BIGENDIAN
129
+ * You should have received a copy of the GNU General Public License along
38
-# define SWAP_WORDS 1
130
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
39
-#endif
131
+ *
40
-
132
+ */
41
-#define FN_2(x) FN(x + 1) FN(x)
133
+
42
-#define FN_4(x) FN_2(x + 2) FN_2(x)
134
+#ifndef ALLWINNER_I2C_H
43
-
135
+#define ALLWINNER_I2C_H
44
-static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src,
136
+
45
- int width, int deststep)
137
+#include "hw/sysbus.h"
46
-{
138
+#include "qom/object.h"
47
- uint32_t *palette = opaque;
139
+
48
- uint32_t data;
140
+#define TYPE_AW_I2C "allwinner.i2c"
49
- while (width > 0) {
141
+OBJECT_DECLARE_SIMPLE_TYPE(AWI2CState, AW_I2C)
50
- data = *(uint32_t *) src;
142
+
51
-#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]);
143
+#define AW_I2C_MEM_SIZE 0x24
52
-#ifdef SWAP_WORDS
144
+
53
- FN_4(12)
145
+struct AWI2CState {
54
- FN_4(8)
146
+ /*< private >*/
55
- FN_4(4)
147
+ SysBusDevice parent_obj;
56
- FN_4(0)
148
+
57
-#else
149
+ /*< public >*/
58
- FN_4(0)
150
+ MemoryRegion iomem;
59
- FN_4(4)
151
+ I2CBus *bus;
60
- FN_4(8)
152
+ qemu_irq irq;
61
- FN_4(12)
153
+
62
-#endif
154
+ uint8_t addr;
63
-#undef FN
155
+ uint8_t xaddr;
64
- width -= 16;
156
+ uint8_t data;
65
- src += 4;
157
+ uint8_t cntr;
66
- }
158
+ uint8_t stat;
67
-}
159
+ uint8_t ccr;
68
-
160
+ uint8_t srst;
69
-static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src,
161
+ uint8_t efr;
70
- int width, int deststep)
162
+ uint8_t lcr;
71
-{
163
+};
72
- uint32_t *palette = opaque;
164
+
73
- uint32_t data;
165
+#endif /* ALLWINNER_I2C_H */
74
- while (width > 0) {
166
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
75
- data = *(uint32_t *) src;
167
index XXXXXXX..XXXXXXX 100644
76
-#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]);
168
--- a/hw/arm/allwinner-a10.c
77
-#ifdef SWAP_WORDS
169
+++ b/hw/arm/allwinner-a10.c
78
- FN_2(6)
170
@@ -XXX,XX +XXX,XX @@
79
- FN_2(4)
171
#define AW_A10_OHCI_BASE 0x01c14400
80
- FN_2(2)
172
#define AW_A10_SATA_BASE 0x01c18000
81
- FN_2(0)
173
#define AW_A10_RTC_BASE 0x01c20d00
82
-#else
174
+#define AW_A10_I2C0_BASE 0x01c2ac00
83
- FN_2(0)
175
84
- FN_2(2)
176
static void aw_a10_init(Object *obj)
85
- FN_2(4)
177
{
86
- FN_2(6)
178
@@ -XXX,XX +XXX,XX @@ static void aw_a10_init(Object *obj)
87
-#endif
179
88
-#undef FN
180
object_initialize_child(obj, "sata", &s->sata, TYPE_ALLWINNER_AHCI);
89
- width -= 8;
181
90
- src += 4;
182
+ object_initialize_child(obj, "i2c0", &s->i2c0, TYPE_AW_I2C);
91
- }
183
+
92
-}
184
if (machine_usb(current_machine)) {
93
-
185
int i;
94
-static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src,
186
95
- int width, int deststep)
187
@@ -XXX,XX +XXX,XX @@ static void aw_a10_realize(DeviceState *dev, Error **errp)
96
-{
188
/* RTC */
97
- uint32_t *palette = opaque;
189
sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &error_fatal);
98
- uint32_t data;
190
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->rtc), 0, AW_A10_RTC_BASE, 10);
99
- while (width > 0) {
191
+
100
- data = *(uint32_t *) src;
192
+ /* I2C */
101
-#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]);
193
+ sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal);
102
-#ifdef SWAP_WORDS
194
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, AW_A10_I2C0_BASE);
103
- FN(24)
195
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0, qdev_get_gpio_in(dev, 7));
104
- FN(16)
196
}
105
- FN(8)
197
106
- FN(0)
198
static void aw_a10_class_init(ObjectClass *oc, void *data)
107
-#else
199
diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c
108
- FN(0)
200
index XXXXXXX..XXXXXXX 100644
109
- FN(8)
201
--- a/hw/arm/allwinner-h3.c
110
- FN(16)
202
+++ b/hw/arm/allwinner-h3.c
111
- FN(24)
203
@@ -XXX,XX +XXX,XX @@ const hwaddr allwinner_h3_memmap[] = {
112
-#endif
204
[AW_H3_DEV_UART1] = 0x01c28400,
113
-#undef FN
205
[AW_H3_DEV_UART2] = 0x01c28800,
114
- width -= 4;
206
[AW_H3_DEV_UART3] = 0x01c28c00,
115
- src += 4;
207
+ [AW_H3_DEV_TWI0] = 0x01c2ac00,
116
- }
208
[AW_H3_DEV_EMAC] = 0x01c30000,
117
-}
209
[AW_H3_DEV_DRAMCOM] = 0x01c62000,
118
-
210
[AW_H3_DEV_DRAMCTL] = 0x01c63000,
119
-static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src,
211
@@ -XXX,XX +XXX,XX @@ struct AwH3Unimplemented {
120
- int width, int deststep)
212
{ "uart1", 0x01c28400, 1 * KiB },
121
-{
213
{ "uart2", 0x01c28800, 1 * KiB },
122
- uint32_t data;
214
{ "uart3", 0x01c28c00, 1 * KiB },
123
- unsigned int r, g, b;
215
- { "twi0", 0x01c2ac00, 1 * KiB },
124
- while (width > 0) {
216
{ "twi1", 0x01c2b000, 1 * KiB },
125
- data = *(uint32_t *) src;
217
{ "twi2", 0x01c2b400, 1 * KiB },
126
-#ifdef SWAP_WORDS
218
{ "scr", 0x01c2c400, 1 * KiB },
127
- data = bswap32(data);
219
@@ -XXX,XX +XXX,XX @@ enum {
128
-#endif
220
AW_H3_GIC_SPI_UART1 = 1,
129
- b = (data & 0x1f) << 3;
221
AW_H3_GIC_SPI_UART2 = 2,
130
- data >>= 5;
222
AW_H3_GIC_SPI_UART3 = 3,
131
- g = (data & 0x3f) << 2;
223
+ AW_H3_GIC_SPI_TWI0 = 6,
132
- data >>= 6;
224
AW_H3_GIC_SPI_TIMER0 = 18,
133
- r = (data & 0x1f) << 3;
225
AW_H3_GIC_SPI_TIMER1 = 19,
134
- data >>= 5;
226
AW_H3_GIC_SPI_MMC0 = 60,
135
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
227
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_init(Object *obj)
136
- b = (data & 0x1f) << 3;
228
"ram-size");
137
- data >>= 5;
229
138
- g = (data & 0x3f) << 2;
230
object_initialize_child(obj, "rtc", &s->rtc, TYPE_AW_RTC_SUN6I);
139
- data >>= 6;
231
+
140
- r = (data & 0x1f) << 3;
232
+ object_initialize_child(obj, "twi0", &s->i2c0, TYPE_AW_I2C);
141
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
233
}
142
- width -= 2;
234
143
- src += 4;
235
static void allwinner_h3_realize(DeviceState *dev, Error **errp)
144
- }
236
@@ -XXX,XX +XXX,XX @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
145
-}
237
sysbus_realize(SYS_BUS_DEVICE(&s->rtc), &error_fatal);
146
-
238
sysbus_mmio_map(SYS_BUS_DEVICE(&s->rtc), 0, s->memmap[AW_H3_DEV_RTC]);
147
-static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src,
239
148
- int width, int deststep)
240
+ /* I2C */
149
-{
241
+ sysbus_realize(SYS_BUS_DEVICE(&s->i2c0), &error_fatal);
150
- uint32_t data;
242
+ sysbus_mmio_map(SYS_BUS_DEVICE(&s->i2c0), 0, s->memmap[AW_H3_DEV_TWI0]);
151
- unsigned int r, g, b;
243
+ sysbus_connect_irq(SYS_BUS_DEVICE(&s->i2c0), 0,
152
- while (width > 0) {
244
+ qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_TWI0));
153
- data = *(uint32_t *) src;
245
+
154
-#ifdef SWAP_WORDS
246
/* Unimplemented devices */
155
- data = bswap32(data);
247
for (i = 0; i < ARRAY_SIZE(unimplemented); i++) {
156
-#endif
248
create_unimplemented_device(unimplemented[i].device_name,
157
- b = (data & 0x1f) << 3;
249
diff --git a/hw/i2c/allwinner-i2c.c b/hw/i2c/allwinner-i2c.c
158
- data >>= 5;
250
new file mode 100644
159
- g = (data & 0x1f) << 3;
251
index XXXXXXX..XXXXXXX
160
- data >>= 5;
252
--- /dev/null
161
- r = (data & 0x1f) << 3;
253
+++ b/hw/i2c/allwinner-i2c.c
162
- data >>= 5;
254
@@ -XXX,XX +XXX,XX @@
163
- if (data & 1) {
255
+/*
164
- SKIP_PIXEL(dest);
256
+ * Allwinner I2C Bus Serial Interface Emulation
165
- } else {
257
+ *
166
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
258
+ * Copyright (C) 2022 Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
167
- }
259
+ *
168
- data >>= 1;
260
+ * This file is derived from IMX I2C controller,
169
- b = (data & 0x1f) << 3;
261
+ * by Jean-Christophe DUBOIS .
170
- data >>= 5;
262
+ *
171
- g = (data & 0x1f) << 3;
263
+ * This program is free software; you can redistribute it and/or modify it
172
- data >>= 5;
264
+ * under the terms of the GNU General Public License as published by the
173
- r = (data & 0x1f) << 3;
265
+ * Free Software Foundation; either version 2 of the License, or
174
- data >>= 5;
266
+ * (at your option) any later version.
175
- if (data & 1) {
267
+ *
176
- SKIP_PIXEL(dest);
268
+ * This program is distributed in the hope that it will be useful, but WITHOUT
177
- } else {
269
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
178
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
270
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
179
- }
271
+ * for more details.
180
- width -= 2;
272
+ *
181
- src += 4;
273
+ * You should have received a copy of the GNU General Public License along
182
- }
274
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
183
-}
275
+ *
184
-
276
+ * SPDX-License-Identifier: MIT
185
-static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src,
277
+ */
186
- int width, int deststep)
278
+
187
-{
279
+#include "qemu/osdep.h"
188
- uint32_t data;
280
+#include "hw/i2c/allwinner-i2c.h"
189
- unsigned int r, g, b;
281
+#include "hw/irq.h"
190
- while (width > 0) {
282
+#include "migration/vmstate.h"
191
- data = *(uint32_t *) src;
283
+#include "hw/i2c/i2c.h"
192
-#ifdef SWAP_WORDS
284
+#include "qemu/log.h"
193
- data = bswap32(data);
285
+#include "trace.h"
194
-#endif
286
+#include "qemu/module.h"
195
- b = (data & 0x3f) << 2;
287
+
196
- data >>= 6;
288
+/* Allwinner I2C memory map */
197
- g = (data & 0x3f) << 2;
289
+#define TWI_ADDR_REG 0x00 /* slave address register */
198
- data >>= 6;
290
+#define TWI_XADDR_REG 0x04 /* extended slave address register */
199
- r = (data & 0x3f) << 2;
291
+#define TWI_DATA_REG 0x08 /* data register */
200
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
292
+#define TWI_CNTR_REG 0x0c /* control register */
201
- width -= 1;
293
+#define TWI_STAT_REG 0x10 /* status register */
202
- src += 4;
294
+#define TWI_CCR_REG 0x14 /* clock control register */
203
- }
295
+#define TWI_SRST_REG 0x18 /* software reset register */
204
-}
296
+#define TWI_EFR_REG 0x1c /* enhance feature register */
205
-
297
+#define TWI_LCR_REG 0x20 /* line control register */
206
-/* The wicked packed format */
298
+
207
-static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src,
299
+/* Used only in slave mode, do not set */
208
- int width, int deststep)
300
+#define TWI_ADDR_RESET 0
209
-{
301
+#define TWI_XADDR_RESET 0
210
- uint32_t data[3];
302
+
211
- unsigned int r, g, b;
303
+/* Data register */
212
- while (width > 0) {
304
+#define TWI_DATA_MASK 0xFF
213
- data[0] = *(uint32_t *) src;
305
+#define TWI_DATA_RESET 0
214
- src += 4;
306
+
215
- data[1] = *(uint32_t *) src;
307
+/* Control register */
216
- src += 4;
308
+#define TWI_CNTR_INT_EN (1 << 7)
217
- data[2] = *(uint32_t *) src;
309
+#define TWI_CNTR_BUS_EN (1 << 6)
218
- src += 4;
310
+#define TWI_CNTR_M_STA (1 << 5)
219
-#ifdef SWAP_WORDS
311
+#define TWI_CNTR_M_STP (1 << 4)
220
- data[0] = bswap32(data[0]);
312
+#define TWI_CNTR_INT_FLAG (1 << 3)
221
- data[1] = bswap32(data[1]);
313
+#define TWI_CNTR_A_ACK (1 << 2)
222
- data[2] = bswap32(data[2]);
314
+#define TWI_CNTR_MASK 0xFC
223
-#endif
315
+#define TWI_CNTR_RESET 0
224
- b = (data[0] & 0x3f) << 2;
316
+
225
- data[0] >>= 6;
317
+/* Status register */
226
- g = (data[0] & 0x3f) << 2;
318
+#define TWI_STAT_MASK 0xF8
227
- data[0] >>= 6;
319
+#define TWI_STAT_RESET 0xF8
228
- r = (data[0] & 0x3f) << 2;
320
+
229
- data[0] >>= 12;
321
+/* Clock register */
230
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
322
+#define TWI_CCR_CLK_M_MASK 0x78
231
- b = (data[0] & 0x3f) << 2;
323
+#define TWI_CCR_CLK_N_MASK 0x07
232
- data[0] >>= 6;
324
+#define TWI_CCR_MASK 0x7F
233
- g = ((data[1] & 0xf) << 4) | (data[0] << 2);
325
+#define TWI_CCR_RESET 0
234
- data[1] >>= 4;
326
+
235
- r = (data[1] & 0x3f) << 2;
327
+/* Soft reset */
236
- data[1] >>= 12;
328
+#define TWI_SRST_MASK 0x01
237
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
329
+#define TWI_SRST_RESET 0
238
- b = (data[1] & 0x3f) << 2;
330
+
239
- data[1] >>= 6;
331
+/* Enhance feature */
240
- g = (data[1] & 0x3f) << 2;
332
+#define TWI_EFR_MASK 0x03
241
- data[1] >>= 6;
333
+#define TWI_EFR_RESET 0
242
- r = ((data[2] & 0x3) << 6) | (data[1] << 2);
334
+
243
- data[2] >>= 8;
335
+/* Line control */
244
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
336
+#define TWI_LCR_SCL_STATE (1 << 5)
245
- b = (data[2] & 0x3f) << 2;
337
+#define TWI_LCR_SDA_STATE (1 << 4)
246
- data[2] >>= 6;
338
+#define TWI_LCR_SCL_CTL (1 << 3)
247
- g = (data[2] & 0x3f) << 2;
339
+#define TWI_LCR_SCL_CTL_EN (1 << 2)
248
- data[2] >>= 6;
340
+#define TWI_LCR_SDA_CTL (1 << 1)
249
- r = data[2] << 2;
341
+#define TWI_LCR_SDA_CTL_EN (1 << 0)
250
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
342
+#define TWI_LCR_MASK 0x3F
251
- width -= 4;
343
+#define TWI_LCR_RESET 0x3A
252
- }
344
+
253
-}
345
+/* Status value in STAT register is shifted by 3 bits */
254
-
346
+#define TWI_STAT_SHIFT 3
255
-static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src,
347
+#define STAT_FROM_STA(x) ((x) << TWI_STAT_SHIFT)
256
- int width, int deststep)
348
+#define STAT_TO_STA(x) ((x) >> TWI_STAT_SHIFT)
257
-{
349
+
258
- uint32_t data;
350
+enum {
259
- unsigned int r, g, b;
351
+ STAT_BUS_ERROR = 0,
260
- while (width > 0) {
352
+ /* Master mode */
261
- data = *(uint32_t *) src;
353
+ STAT_M_STA_TX,
262
-#ifdef SWAP_WORDS
354
+ STAT_M_RSTA_TX,
263
- data = bswap32(data);
355
+ STAT_M_ADDR_WR_ACK,
264
-#endif
356
+ STAT_M_ADDR_WR_NACK,
265
- b = (data & 0x3f) << 2;
357
+ STAT_M_DATA_TX_ACK,
266
- data >>= 6;
358
+ STAT_M_DATA_TX_NACK,
267
- g = (data & 0x3f) << 2;
359
+ STAT_M_ARB_LOST,
268
- data >>= 6;
360
+ STAT_M_ADDR_RD_ACK,
269
- r = (data & 0x3f) << 2;
361
+ STAT_M_ADDR_RD_NACK,
270
- data >>= 6;
362
+ STAT_M_DATA_RX_ACK,
271
- if (data & 1) {
363
+ STAT_M_DATA_RX_NACK,
272
- SKIP_PIXEL(dest);
364
+ /* Slave mode */
273
- } else {
365
+ STAT_S_ADDR_WR_ACK,
274
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
366
+ STAT_S_ARB_LOST_AW_ACK,
275
- }
367
+ STAT_S_GCA_ACK,
276
- width -= 1;
368
+ STAT_S_ARB_LOST_GCA_ACK,
277
- src += 4;
369
+ STAT_S_DATA_RX_SA_ACK,
278
- }
370
+ STAT_S_DATA_RX_SA_NACK,
279
-}
371
+ STAT_S_DATA_RX_GCA_ACK,
280
-
372
+ STAT_S_DATA_RX_GCA_NACK,
281
-/* The wicked packed format */
373
+ STAT_S_STP_RSTA,
282
-static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src,
374
+ STAT_S_ADDR_RD_ACK,
283
- int width, int deststep)
375
+ STAT_S_ARB_LOST_AR_ACK,
284
-{
376
+ STAT_S_DATA_TX_ACK,
285
- uint32_t data[3];
377
+ STAT_S_DATA_TX_NACK,
286
- unsigned int r, g, b;
378
+ STAT_S_LB_TX_ACK,
287
- while (width > 0) {
379
+ /* Master mode, 10-bit */
288
- data[0] = *(uint32_t *) src;
380
+ STAT_M_2ND_ADDR_WR_ACK,
289
- src += 4;
381
+ STAT_M_2ND_ADDR_WR_NACK,
290
- data[1] = *(uint32_t *) src;
382
+ /* Idle */
291
- src += 4;
383
+ STAT_IDLE = 0x1f
292
- data[2] = *(uint32_t *) src;
384
+} TWI_STAT_STA;
293
- src += 4;
385
+
294
-# ifdef SWAP_WORDS
386
+static const char *allwinner_i2c_get_regname(unsigned offset)
295
- data[0] = bswap32(data[0]);
387
+{
296
- data[1] = bswap32(data[1]);
388
+ switch (offset) {
297
- data[2] = bswap32(data[2]);
389
+ case TWI_ADDR_REG:
298
-# endif
390
+ return "ADDR";
299
- b = (data[0] & 0x3f) << 2;
391
+ case TWI_XADDR_REG:
300
- data[0] >>= 6;
392
+ return "XADDR";
301
- g = (data[0] & 0x3f) << 2;
393
+ case TWI_DATA_REG:
302
- data[0] >>= 6;
394
+ return "DATA";
303
- r = (data[0] & 0x3f) << 2;
395
+ case TWI_CNTR_REG:
304
- data[0] >>= 6;
396
+ return "CNTR";
305
- if (data[0] & 1) {
397
+ case TWI_STAT_REG:
306
- SKIP_PIXEL(dest);
398
+ return "STAT";
307
- } else {
399
+ case TWI_CCR_REG:
308
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
400
+ return "CCR";
309
- }
401
+ case TWI_SRST_REG:
310
- data[0] >>= 6;
402
+ return "SRST";
311
- b = (data[0] & 0x3f) << 2;
403
+ case TWI_EFR_REG:
312
- data[0] >>= 6;
404
+ return "EFR";
313
- g = ((data[1] & 0xf) << 4) | (data[0] << 2);
405
+ case TWI_LCR_REG:
314
- data[1] >>= 4;
406
+ return "LCR";
315
- r = (data[1] & 0x3f) << 2;
407
+ default:
316
- data[1] >>= 6;
408
+ return "[?]";
317
- if (data[1] & 1) {
318
- SKIP_PIXEL(dest);
319
- } else {
320
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
321
- }
322
- data[1] >>= 6;
323
- b = (data[1] & 0x3f) << 2;
324
- data[1] >>= 6;
325
- g = (data[1] & 0x3f) << 2;
326
- data[1] >>= 6;
327
- r = ((data[2] & 0x3) << 6) | (data[1] << 2);
328
- data[2] >>= 2;
329
- if (data[2] & 1) {
330
- SKIP_PIXEL(dest);
331
- } else {
332
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
333
- }
334
- data[2] >>= 6;
335
- b = (data[2] & 0x3f) << 2;
336
- data[2] >>= 6;
337
- g = (data[2] & 0x3f) << 2;
338
- data[2] >>= 6;
339
- r = data[2] << 2;
340
- data[2] >>= 6;
341
- if (data[2] & 1) {
342
- SKIP_PIXEL(dest);
343
- } else {
344
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
345
- }
346
- width -= 4;
347
- }
348
-}
349
-
350
-static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src,
351
- int width, int deststep)
352
-{
353
- uint32_t data;
354
- unsigned int r, g, b;
355
- while (width > 0) {
356
- data = *(uint32_t *) src;
357
-#ifdef SWAP_WORDS
358
- data = bswap32(data);
359
-#endif
360
- b = data & 0xff;
361
- data >>= 8;
362
- g = data & 0xff;
363
- data >>= 8;
364
- r = data & 0xff;
365
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
366
- width -= 1;
367
- src += 4;
368
- }
369
-}
370
-
371
-static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src,
372
- int width, int deststep)
373
-{
374
- uint32_t data;
375
- unsigned int r, g, b;
376
- while (width > 0) {
377
- data = *(uint32_t *) src;
378
-#ifdef SWAP_WORDS
379
- data = bswap32(data);
380
-#endif
381
- b = (data & 0x7f) << 1;
382
- data >>= 7;
383
- g = data & 0xff;
384
- data >>= 8;
385
- r = data & 0xff;
386
- data >>= 8;
387
- if (data & 1) {
388
- SKIP_PIXEL(dest);
389
- } else {
390
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
391
- }
392
- width -= 1;
393
- src += 4;
394
- }
395
-}
396
-
397
-static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src,
398
- int width, int deststep)
399
-{
400
- uint32_t data;
401
- unsigned int r, g, b;
402
- while (width > 0) {
403
- data = *(uint32_t *) src;
404
-#ifdef SWAP_WORDS
405
- data = bswap32(data);
406
-#endif
407
- b = data & 0xff;
408
- data >>= 8;
409
- g = data & 0xff;
410
- data >>= 8;
411
- r = data & 0xff;
412
- data >>= 8;
413
- if (data & 1) {
414
- SKIP_PIXEL(dest);
415
- } else {
416
- COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
417
- }
418
- width -= 1;
419
- src += 4;
420
- }
421
-}
422
-
423
-/* Overlay planes disabled, no transparency */
424
-static drawfn pxa2xx_draw_fn_32[16] = {
425
- [0 ... 0xf] = NULL,
426
- [pxa_lcdc_2bpp] = pxa2xx_draw_line2,
427
- [pxa_lcdc_4bpp] = pxa2xx_draw_line4,
428
- [pxa_lcdc_8bpp] = pxa2xx_draw_line8,
429
- [pxa_lcdc_16bpp] = pxa2xx_draw_line16,
430
- [pxa_lcdc_18bpp] = pxa2xx_draw_line18,
431
- [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p,
432
- [pxa_lcdc_24bpp] = pxa2xx_draw_line24,
433
-};
434
-
435
-/* Overlay planes enabled, transparency used */
436
-static drawfn pxa2xx_draw_fn_32t[16] = {
437
- [0 ... 0xf] = NULL,
438
- [pxa_lcdc_4bpp] = pxa2xx_draw_line4,
439
- [pxa_lcdc_8bpp] = pxa2xx_draw_line8,
440
- [pxa_lcdc_16bpp] = pxa2xx_draw_line16t,
441
- [pxa_lcdc_19bpp] = pxa2xx_draw_line19,
442
- [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p,
443
- [pxa_lcdc_24bpp] = pxa2xx_draw_line24t,
444
- [pxa_lcdc_25bpp] = pxa2xx_draw_line25,
445
-};
446
-
447
-#undef COPY_PIXEL
448
-#undef SKIP_PIXEL
449
-
450
-#ifdef SWAP_WORDS
451
-# undef SWAP_WORDS
452
-#endif
453
diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c
454
index XXXXXXX..XXXXXXX 100644
455
--- a/hw/display/pxa2xx_lcd.c
456
+++ b/hw/display/pxa2xx_lcd.c
457
@@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED {
458
/* Size of a pixel in the QEMU UI output surface, in bytes */
459
#define DEST_PIXEL_WIDTH 4
460
461
-#define BITS 32
462
-#include "pxa2xx_template.h"
463
+/* Line drawing code to handle the various possible guest pixel formats */
464
+
465
+# define SKIP_PIXEL(to) do { to += deststep; } while (0)
466
+# define COPY_PIXEL(to, from) \
467
+ do { \
468
+ *(uint32_t *) to = from; \
469
+ SKIP_PIXEL(to); \
470
+ } while (0)
471
+
472
+#ifdef HOST_WORDS_BIGENDIAN
473
+# define SWAP_WORDS 1
474
+#endif
475
+
476
+#define FN_2(x) FN(x + 1) FN(x)
477
+#define FN_4(x) FN_2(x + 2) FN_2(x)
478
+
479
+static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src,
480
+ int width, int deststep)
481
+{
482
+ uint32_t *palette = opaque;
483
+ uint32_t data;
484
+ while (width > 0) {
485
+ data = *(uint32_t *) src;
486
+#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]);
487
+#ifdef SWAP_WORDS
488
+ FN_4(12)
489
+ FN_4(8)
490
+ FN_4(4)
491
+ FN_4(0)
492
+#else
493
+ FN_4(0)
494
+ FN_4(4)
495
+ FN_4(8)
496
+ FN_4(12)
497
+#endif
498
+#undef FN
499
+ width -= 16;
500
+ src += 4;
501
+ }
409
+ }
502
+}
410
+}
503
+
411
+
504
+static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src,
412
+static inline bool allwinner_i2c_is_reset(AWI2CState *s)
505
+ int width, int deststep)
413
+{
506
+{
414
+ return s->srst & TWI_SRST_MASK;
507
+ uint32_t *palette = opaque;
415
+}
508
+ uint32_t data;
416
+
509
+ while (width > 0) {
417
+static inline bool allwinner_i2c_bus_is_enabled(AWI2CState *s)
510
+ data = *(uint32_t *) src;
418
+{
511
+#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]);
419
+ return s->cntr & TWI_CNTR_BUS_EN;
512
+#ifdef SWAP_WORDS
420
+}
513
+ FN_2(6)
421
+
514
+ FN_2(4)
422
+static inline bool allwinner_i2c_interrupt_is_enabled(AWI2CState *s)
515
+ FN_2(2)
423
+{
516
+ FN_2(0)
424
+ return s->cntr & TWI_CNTR_INT_EN;
517
+#else
425
+}
518
+ FN_2(0)
426
+
519
+ FN_2(2)
427
+static void allwinner_i2c_reset_hold(Object *obj)
520
+ FN_2(4)
428
+{
521
+ FN_2(6)
429
+ AWI2CState *s = AW_I2C(obj);
522
+#endif
430
+
523
+#undef FN
431
+ if (STAT_TO_STA(s->stat) != STAT_IDLE) {
524
+ width -= 8;
432
+ i2c_end_transfer(s->bus);
525
+ src += 4;
526
+ }
433
+ }
527
+}
434
+
528
+
435
+ s->addr = TWI_ADDR_RESET;
529
+static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src,
436
+ s->xaddr = TWI_XADDR_RESET;
530
+ int width, int deststep)
437
+ s->data = TWI_DATA_RESET;
531
+{
438
+ s->cntr = TWI_CNTR_RESET;
532
+ uint32_t *palette = opaque;
439
+ s->stat = TWI_STAT_RESET;
533
+ uint32_t data;
440
+ s->ccr = TWI_CCR_RESET;
534
+ while (width > 0) {
441
+ s->srst = TWI_SRST_RESET;
535
+ data = *(uint32_t *) src;
442
+ s->efr = TWI_EFR_RESET;
536
+#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]);
443
+ s->lcr = TWI_LCR_RESET;
537
+#ifdef SWAP_WORDS
444
+}
538
+ FN(24)
445
+
539
+ FN(16)
446
+static inline void allwinner_i2c_raise_interrupt(AWI2CState *s)
540
+ FN(8)
447
+{
541
+ FN(0)
448
+ /*
542
+#else
449
+ * Raise an interrupt if the device is not reset and it is configured
543
+ FN(0)
450
+ * to generate some interrupts.
544
+ FN(8)
451
+ */
545
+ FN(16)
452
+ if (!allwinner_i2c_is_reset(s) && allwinner_i2c_bus_is_enabled(s)) {
546
+ FN(24)
453
+ if (STAT_TO_STA(s->stat) != STAT_IDLE) {
547
+#endif
454
+ s->cntr |= TWI_CNTR_INT_FLAG;
548
+#undef FN
455
+ if (allwinner_i2c_interrupt_is_enabled(s)) {
549
+ width -= 4;
456
+ qemu_irq_raise(s->irq);
550
+ src += 4;
457
+ }
458
+ }
551
+ }
459
+ }
552
+}
460
+}
553
+
461
+
554
+static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src,
462
+static uint64_t allwinner_i2c_read(void *opaque, hwaddr offset,
555
+ int width, int deststep)
463
+ unsigned size)
556
+{
464
+{
557
+ uint32_t data;
465
+ uint16_t value;
558
+ unsigned int r, g, b;
466
+ AWI2CState *s = AW_I2C(opaque);
559
+ while (width > 0) {
467
+
560
+ data = *(uint32_t *) src;
468
+ switch (offset) {
561
+#ifdef SWAP_WORDS
469
+ case TWI_ADDR_REG:
562
+ data = bswap32(data);
470
+ value = s->addr;
563
+#endif
471
+ break;
564
+ b = (data & 0x1f) << 3;
472
+ case TWI_XADDR_REG:
565
+ data >>= 5;
473
+ value = s->xaddr;
566
+ g = (data & 0x3f) << 2;
474
+ break;
567
+ data >>= 6;
475
+ case TWI_DATA_REG:
568
+ r = (data & 0x1f) << 3;
476
+ if ((STAT_TO_STA(s->stat) == STAT_M_ADDR_RD_ACK) ||
569
+ data >>= 5;
477
+ (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_ACK) ||
570
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
478
+ (STAT_TO_STA(s->stat) == STAT_M_DATA_RX_NACK)) {
571
+ b = (data & 0x1f) << 3;
479
+ /* Get the next byte */
572
+ data >>= 5;
480
+ s->data = i2c_recv(s->bus);
573
+ g = (data & 0x3f) << 2;
481
+
574
+ data >>= 6;
482
+ if (s->cntr & TWI_CNTR_A_ACK) {
575
+ r = (data & 0x1f) << 3;
483
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_ACK);
576
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
484
+ } else {
577
+ width -= 2;
485
+ s->stat = STAT_FROM_STA(STAT_M_DATA_RX_NACK);
578
+ src += 4;
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;
579
+ }
526
+ }
580
+}
527
+
581
+
528
+ trace_allwinner_i2c_read(allwinner_i2c_get_regname(offset), offset, value);
582
+static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src,
529
+
583
+ int width, int deststep)
530
+ return (uint64_t)value;
584
+{
531
+}
585
+ uint32_t data;
532
+
586
+ unsigned int r, g, b;
533
+static void allwinner_i2c_write(void *opaque, hwaddr offset,
587
+ while (width > 0) {
534
+ uint64_t value, unsigned size)
588
+ data = *(uint32_t *) src;
535
+{
589
+#ifdef SWAP_WORDS
536
+ AWI2CState *s = AW_I2C(opaque);
590
+ data = bswap32(data);
537
+
591
+#endif
538
+ value &= 0xff;
592
+ b = (data & 0x1f) << 3;
539
+
593
+ data >>= 5;
540
+ trace_allwinner_i2c_write(allwinner_i2c_get_regname(offset), offset, value);
594
+ g = (data & 0x1f) << 3;
541
+
595
+ data >>= 5;
542
+ switch (offset) {
596
+ r = (data & 0x1f) << 3;
543
+ case TWI_ADDR_REG:
597
+ data >>= 5;
544
+ s->addr = (uint8_t)value;
598
+ if (data & 1) {
545
+ break;
599
+ SKIP_PIXEL(dest);
546
+ case TWI_XADDR_REG:
600
+ } else {
547
+ s->xaddr = (uint8_t)value;
601
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
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;
602
+ }
553
+ }
603
+ data >>= 1;
554
+
604
+ b = (data & 0x1f) << 3;
555
+ s->data = value & TWI_DATA_MASK;
605
+ data >>= 5;
556
+
606
+ g = (data & 0x1f) << 3;
557
+ switch (STAT_TO_STA(s->stat)) {
607
+ data >>= 5;
558
+ case STAT_M_STA_TX:
608
+ r = (data & 0x1f) << 3;
559
+ case STAT_M_RSTA_TX:
609
+ data >>= 5;
560
+ /* Send address */
610
+ if (data & 1) {
561
+ if (i2c_start_transfer(s->bus, extract32(s->data, 1, 7),
611
+ SKIP_PIXEL(dest);
562
+ extract32(s->data, 0, 1))) {
612
+ } else {
563
+ /* If non zero is returned, the address is not valid */
613
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
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;
614
+ }
588
+ }
615
+ width -= 2;
589
+ break;
616
+ src += 4;
590
+ case TWI_CNTR_REG:
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
+
629
+ }
630
+ break;
631
+ case TWI_CCR_REG:
632
+ s->ccr = value & TWI_CCR_MASK;
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));
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;
617
+ }
651
+ }
618
+}
652
+}
619
+
653
+
620
+static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src,
654
+static const MemoryRegionOps allwinner_i2c_ops = {
621
+ int width, int deststep)
655
+ .read = allwinner_i2c_read,
622
+{
656
+ .write = allwinner_i2c_write,
623
+ uint32_t data;
657
+ .valid.min_access_size = 1,
624
+ unsigned int r, g, b;
658
+ .valid.max_access_size = 4,
625
+ while (width > 0) {
659
+ .endianness = DEVICE_NATIVE_ENDIAN,
626
+ data = *(uint32_t *) src;
660
+};
627
+#ifdef SWAP_WORDS
661
+
628
+ data = bswap32(data);
662
+static const VMStateDescription allwinner_i2c_vmstate = {
629
+#endif
663
+ .name = TYPE_AW_I2C,
630
+ b = (data & 0x3f) << 2;
664
+ .version_id = 1,
631
+ data >>= 6;
665
+ .minimum_version_id = 1,
632
+ g = (data & 0x3f) << 2;
666
+ .fields = (VMStateField[]) {
633
+ data >>= 6;
667
+ VMSTATE_UINT8(addr, AWI2CState),
634
+ r = (data & 0x3f) << 2;
668
+ VMSTATE_UINT8(xaddr, AWI2CState),
635
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
669
+ VMSTATE_UINT8(data, AWI2CState),
636
+ width -= 1;
670
+ VMSTATE_UINT8(cntr, AWI2CState),
637
+ src += 4;
671
+ VMSTATE_UINT8(ccr, AWI2CState),
672
+ VMSTATE_UINT8(srst, AWI2CState),
673
+ VMSTATE_UINT8(efr, AWI2CState),
674
+ VMSTATE_UINT8(lcr, AWI2CState),
675
+ VMSTATE_END_OF_LIST()
638
+ }
676
+ }
639
+}
640
+
641
+/* The wicked packed format */
642
+static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src,
643
+ int width, int deststep)
644
+{
645
+ uint32_t data[3];
646
+ unsigned int r, g, b;
647
+ while (width > 0) {
648
+ data[0] = *(uint32_t *) src;
649
+ src += 4;
650
+ data[1] = *(uint32_t *) src;
651
+ src += 4;
652
+ data[2] = *(uint32_t *) src;
653
+ src += 4;
654
+#ifdef SWAP_WORDS
655
+ data[0] = bswap32(data[0]);
656
+ data[1] = bswap32(data[1]);
657
+ data[2] = bswap32(data[2]);
658
+#endif
659
+ b = (data[0] & 0x3f) << 2;
660
+ data[0] >>= 6;
661
+ g = (data[0] & 0x3f) << 2;
662
+ data[0] >>= 6;
663
+ r = (data[0] & 0x3f) << 2;
664
+ data[0] >>= 12;
665
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
666
+ b = (data[0] & 0x3f) << 2;
667
+ data[0] >>= 6;
668
+ g = ((data[1] & 0xf) << 4) | (data[0] << 2);
669
+ data[1] >>= 4;
670
+ r = (data[1] & 0x3f) << 2;
671
+ data[1] >>= 12;
672
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
673
+ b = (data[1] & 0x3f) << 2;
674
+ data[1] >>= 6;
675
+ g = (data[1] & 0x3f) << 2;
676
+ data[1] >>= 6;
677
+ r = ((data[2] & 0x3) << 6) | (data[1] << 2);
678
+ data[2] >>= 8;
679
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
680
+ b = (data[2] & 0x3f) << 2;
681
+ data[2] >>= 6;
682
+ g = (data[2] & 0x3f) << 2;
683
+ data[2] >>= 6;
684
+ r = data[2] << 2;
685
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
686
+ width -= 4;
687
+ }
688
+}
689
+
690
+static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src,
691
+ int width, int deststep)
692
+{
693
+ uint32_t data;
694
+ unsigned int r, g, b;
695
+ while (width > 0) {
696
+ data = *(uint32_t *) src;
697
+#ifdef SWAP_WORDS
698
+ data = bswap32(data);
699
+#endif
700
+ b = (data & 0x3f) << 2;
701
+ data >>= 6;
702
+ g = (data & 0x3f) << 2;
703
+ data >>= 6;
704
+ r = (data & 0x3f) << 2;
705
+ data >>= 6;
706
+ if (data & 1) {
707
+ SKIP_PIXEL(dest);
708
+ } else {
709
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
710
+ }
711
+ width -= 1;
712
+ src += 4;
713
+ }
714
+}
715
+
716
+/* The wicked packed format */
717
+static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src,
718
+ int width, int deststep)
719
+{
720
+ uint32_t data[3];
721
+ unsigned int r, g, b;
722
+ while (width > 0) {
723
+ data[0] = *(uint32_t *) src;
724
+ src += 4;
725
+ data[1] = *(uint32_t *) src;
726
+ src += 4;
727
+ data[2] = *(uint32_t *) src;
728
+ src += 4;
729
+# ifdef SWAP_WORDS
730
+ data[0] = bswap32(data[0]);
731
+ data[1] = bswap32(data[1]);
732
+ data[2] = bswap32(data[2]);
733
+# endif
734
+ b = (data[0] & 0x3f) << 2;
735
+ data[0] >>= 6;
736
+ g = (data[0] & 0x3f) << 2;
737
+ data[0] >>= 6;
738
+ r = (data[0] & 0x3f) << 2;
739
+ data[0] >>= 6;
740
+ if (data[0] & 1) {
741
+ SKIP_PIXEL(dest);
742
+ } else {
743
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
744
+ }
745
+ data[0] >>= 6;
746
+ b = (data[0] & 0x3f) << 2;
747
+ data[0] >>= 6;
748
+ g = ((data[1] & 0xf) << 4) | (data[0] << 2);
749
+ data[1] >>= 4;
750
+ r = (data[1] & 0x3f) << 2;
751
+ data[1] >>= 6;
752
+ if (data[1] & 1) {
753
+ SKIP_PIXEL(dest);
754
+ } else {
755
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
756
+ }
757
+ data[1] >>= 6;
758
+ b = (data[1] & 0x3f) << 2;
759
+ data[1] >>= 6;
760
+ g = (data[1] & 0x3f) << 2;
761
+ data[1] >>= 6;
762
+ r = ((data[2] & 0x3) << 6) | (data[1] << 2);
763
+ data[2] >>= 2;
764
+ if (data[2] & 1) {
765
+ SKIP_PIXEL(dest);
766
+ } else {
767
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
768
+ }
769
+ data[2] >>= 6;
770
+ b = (data[2] & 0x3f) << 2;
771
+ data[2] >>= 6;
772
+ g = (data[2] & 0x3f) << 2;
773
+ data[2] >>= 6;
774
+ r = data[2] << 2;
775
+ data[2] >>= 6;
776
+ if (data[2] & 1) {
777
+ SKIP_PIXEL(dest);
778
+ } else {
779
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
780
+ }
781
+ width -= 4;
782
+ }
783
+}
784
+
785
+static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src,
786
+ int width, int deststep)
787
+{
788
+ uint32_t data;
789
+ unsigned int r, g, b;
790
+ while (width > 0) {
791
+ data = *(uint32_t *) src;
792
+#ifdef SWAP_WORDS
793
+ data = bswap32(data);
794
+#endif
795
+ b = data & 0xff;
796
+ data >>= 8;
797
+ g = data & 0xff;
798
+ data >>= 8;
799
+ r = data & 0xff;
800
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
801
+ width -= 1;
802
+ src += 4;
803
+ }
804
+}
805
+
806
+static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src,
807
+ int width, int deststep)
808
+{
809
+ uint32_t data;
810
+ unsigned int r, g, b;
811
+ while (width > 0) {
812
+ data = *(uint32_t *) src;
813
+#ifdef SWAP_WORDS
814
+ data = bswap32(data);
815
+#endif
816
+ b = (data & 0x7f) << 1;
817
+ data >>= 7;
818
+ g = data & 0xff;
819
+ data >>= 8;
820
+ r = data & 0xff;
821
+ data >>= 8;
822
+ if (data & 1) {
823
+ SKIP_PIXEL(dest);
824
+ } else {
825
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
826
+ }
827
+ width -= 1;
828
+ src += 4;
829
+ }
830
+}
831
+
832
+static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src,
833
+ int width, int deststep)
834
+{
835
+ uint32_t data;
836
+ unsigned int r, g, b;
837
+ while (width > 0) {
838
+ data = *(uint32_t *) src;
839
+#ifdef SWAP_WORDS
840
+ data = bswap32(data);
841
+#endif
842
+ b = data & 0xff;
843
+ data >>= 8;
844
+ g = data & 0xff;
845
+ data >>= 8;
846
+ r = data & 0xff;
847
+ data >>= 8;
848
+ if (data & 1) {
849
+ SKIP_PIXEL(dest);
850
+ } else {
851
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
852
+ }
853
+ width -= 1;
854
+ src += 4;
855
+ }
856
+}
857
+
858
+/* Overlay planes disabled, no transparency */
859
+static drawfn pxa2xx_draw_fn_32[16] = {
860
+ [0 ... 0xf] = NULL,
861
+ [pxa_lcdc_2bpp] = pxa2xx_draw_line2,
862
+ [pxa_lcdc_4bpp] = pxa2xx_draw_line4,
863
+ [pxa_lcdc_8bpp] = pxa2xx_draw_line8,
864
+ [pxa_lcdc_16bpp] = pxa2xx_draw_line16,
865
+ [pxa_lcdc_18bpp] = pxa2xx_draw_line18,
866
+ [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p,
867
+ [pxa_lcdc_24bpp] = pxa2xx_draw_line24,
868
+};
677
+};
869
+
678
+
870
+/* Overlay planes enabled, transparency used */
679
+static void allwinner_i2c_realize(DeviceState *dev, Error **errp)
871
+static drawfn pxa2xx_draw_fn_32t[16] = {
680
+{
872
+ [0 ... 0xf] = NULL,
681
+ AWI2CState *s = AW_I2C(dev);
873
+ [pxa_lcdc_4bpp] = pxa2xx_draw_line4,
682
+
874
+ [pxa_lcdc_8bpp] = pxa2xx_draw_line8,
683
+ memory_region_init_io(&s->iomem, OBJECT(s), &allwinner_i2c_ops, s,
875
+ [pxa_lcdc_16bpp] = pxa2xx_draw_line16t,
684
+ TYPE_AW_I2C, AW_I2C_MEM_SIZE);
876
+ [pxa_lcdc_19bpp] = pxa2xx_draw_line19,
685
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
877
+ [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p,
686
+ sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
878
+ [pxa_lcdc_24bpp] = pxa2xx_draw_line24t,
687
+ s->bus = i2c_init_bus(dev, "i2c");
879
+ [pxa_lcdc_25bpp] = pxa2xx_draw_line25,
688
+}
689
+
690
+static void allwinner_i2c_class_init(ObjectClass *klass, void *data)
691
+{
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,
880
+};
706
+};
881
+
707
+
882
+#undef COPY_PIXEL
708
+static void allwinner_i2c_register_types(void)
883
+#undef SKIP_PIXEL
709
+{
884
+
710
+ type_register_static(&allwinner_i2c_type_info);
885
+#ifdef SWAP_WORDS
711
+}
886
+# undef SWAP_WORDS
712
+
887
+#endif
713
+type_init(allwinner_i2c_register_types)
888
714
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
889
/* Route internal interrupt lines to the global IC */
715
index XXXXXXX..XXXXXXX 100644
890
static void pxa2xx_lcdc_int_update(PXA2xxLCDState *s)
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"
891
--
777
--
892
2.20.1
778
2.34.1
893
894
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
Missed out on compressing the second half of a predicate
3
This patch adds minimal support for AXP-209 PMU.
4
with length vl % 512 > 256.
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.
5
7
6
Adjust all of the x + (y << s) to x | (y << s) as a
8
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
7
general style fix. Drop the extract64 because the input
9
Message-id: 20221226220303.14420-5-strahinja.p.jankovic@gmail.com
8
uint64_t are known to be already zero-extended from the
9
current size of the predicate.
10
11
Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20210309155305.11301-2-richard.henderson@linaro.org
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
12
---
17
target/arm/sve_helper.c | 30 +++++++++++++++++++++---------
13
hw/misc/axp209.c | 238 +++++++++++++++++++++++++++++++++++++++++++
18
1 file changed, 21 insertions(+), 9 deletions(-)
14
MAINTAINERS | 2 +
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
19
20
20
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
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
21
index XXXXXXX..XXXXXXX 100644
266
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/sve_helper.c
267
--- a/MAINTAINERS
23
+++ b/target/arm/sve_helper.c
268
+++ b/MAINTAINERS
24
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
269
@@ -XXX,XX +XXX,XX @@ ARM Machines
25
if (oprsz <= 8) {
270
Allwinner-a10
26
l = compress_bits(n[0] >> odd, esz);
271
M: Beniamino Galvani <b.galvani@gmail.com>
27
h = compress_bits(m[0] >> odd, esz);
272
M: Peter Maydell <peter.maydell@linaro.org>
28
- d[0] = extract64(l + (h << (4 * oprsz)), 0, 8 * oprsz);
273
+R: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
29
+ d[0] = l | (h << (4 * oprsz));
274
L: qemu-arm@nongnu.org
30
} else {
275
S: Odd Fixes
31
ARMPredicateReg tmp_m;
276
F: hw/*/allwinner*
32
intptr_t oprsz_16 = oprsz / 16;
277
F: include/hw/*/allwinner*
33
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
278
F: hw/arm/cubieboard.c
34
h = n[2 * i + 1];
279
F: docs/system/arm/cubieboard.rst
35
l = compress_bits(l >> odd, esz);
280
+F: hw/misc/axp209.c
36
h = compress_bits(h >> odd, esz);
281
37
- d[i] = l + (h << 32);
282
Allwinner-h3
38
+ d[i] = l | (h << 32);
283
M: Niek Linnenbank <nieklinnenbank@gmail.com>
39
}
284
diff --git a/hw/misc/Kconfig b/hw/misc/Kconfig
40
285
index XXXXXXX..XXXXXXX 100644
41
- /* For VL which is not a power of 2, the results from M do not
286
--- a/hw/misc/Kconfig
42
- align nicely with the uint64_t for D. Put the aligned results
287
+++ b/hw/misc/Kconfig
43
- from M into TMP_M and then copy it into place afterward. */
288
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10_CCM
44
+ /*
289
config ALLWINNER_A10_DRAMC
45
+ * For VL which is not a multiple of 512, the results from M do not
290
bool
46
+ * align nicely with the uint64_t for D. Put the aligned results
291
47
+ * from M into TMP_M and then copy it into place afterward.
292
+config AXP209_PMU
48
+ */
293
+ bool
49
if (oprsz & 15) {
294
+ depends on I2C
50
- d[i] = compress_bits(n[2 * i] >> odd, esz);
295
+
51
+ int final_shift = (oprsz & 15) * 2;
296
source macio/Kconfig
52
+
297
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
53
+ l = n[2 * i + 0];
298
index XXXXXXX..XXXXXXX 100644
54
+ h = n[2 * i + 1];
299
--- a/hw/misc/meson.build
55
+ l = compress_bits(l >> odd, esz);
300
+++ b/hw/misc/meson.build
56
+ h = compress_bits(h >> odd, esz);
301
@@ -XXX,XX +XXX,XX @@ specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c'
57
+ d[i] = l | (h << final_shift);
302
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c'))
58
303
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-sysctrl.c'))
59
for (i = 0; i < oprsz_16; i++) {
304
softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sid.c'))
60
l = m[2 * i + 0];
305
+softmmu_ss.add(when: 'CONFIG_AXP209_PMU', if_true: files('axp209.c'))
61
h = m[2 * i + 1];
306
softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('arm_sysctl.c'))
62
l = compress_bits(l >> odd, esz);
307
softmmu_ss.add(when: 'CONFIG_NSERIES', if_true: files('cbus.c'))
63
h = compress_bits(h >> odd, esz);
308
softmmu_ss.add(when: 'CONFIG_ECCMEMCTL', if_true: files('eccmemctl.c'))
64
- tmp_m.p[i] = l + (h << 32);
309
diff --git a/hw/misc/trace-events b/hw/misc/trace-events
65
+ tmp_m.p[i] = l | (h << 32);
310
index XXXXXXX..XXXXXXX 100644
66
}
311
--- a/hw/misc/trace-events
67
- tmp_m.p[i] = compress_bits(m[2 * i] >> odd, esz);
312
+++ b/hw/misc/trace-events
68
+ l = m[2 * i + 0];
313
@@ -XXX,XX +XXX,XX @@ allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%"
69
+ h = m[2 * i + 1];
314
avr_power_read(uint8_t value) "power_reduc read value:%u"
70
+ l = compress_bits(l >> odd, esz);
315
avr_power_write(uint8_t value) "power_reduc write value:%u"
71
+ h = compress_bits(h >> odd, esz);
316
72
+ tmp_m.p[i] = l | (h << final_shift);
317
+# axp209.c
73
318
+axp209_rx(uint8_t reg, uint8_t data) "Read reg 0x%" PRIx8 " : 0x%" PRIx8
74
swap_memmove(vd + oprsz / 2, &tmp_m, oprsz / 2);
319
+axp209_select(uint8_t reg) "Accessing reg 0x%" PRIx8
75
} else {
320
+axp209_tx(uint8_t reg, uint8_t data) "Write reg 0x%" PRIx8 " : 0x%" PRIx8
76
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_uzp_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
321
+
77
h = m[2 * i + 1];
322
# eccmemctl.c
78
l = compress_bits(l >> odd, esz);
323
ecc_mem_writel_mer(uint32_t val) "Write memory enable 0x%08x"
79
h = compress_bits(h >> odd, esz);
324
ecc_mem_writel_mdr(uint32_t val) "Write memory delay 0x%08x"
80
- d[oprsz_16 + i] = l + (h << 32);
81
+ d[oprsz_16 + i] = l | (h << 32);
82
}
83
}
84
}
85
--
325
--
86
2.20.1
326
2.34.1
87
88
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
With the reduction operations, we intentionally increase maxsz to
3
SPL Boot for Cubieboard expects AXP209 connected to I2C0 bus.
4
the next power of 2, so as to fill out the reduction tree correctly.
5
Since e2e7168a214b, oprsz must equal maxsz, with exceptions for small
6
vectors, so this triggers an assertion for vector sizes > 32 that are
7
not themselves a power of 2.
8
4
9
Pass the power-of-two value in the simd_data field instead.
5
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
10
6
11
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Message-id: 20210309155305.11301-9-richard.henderson@linaro.org
8
Message-id: 20221226220303.14420-6-strahinja.p.jankovic@gmail.com
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
10
---
16
target/arm/sve_helper.c | 2 +-
11
hw/arm/cubieboard.c | 6 ++++++
17
target/arm/translate-sve.c | 2 +-
12
hw/arm/Kconfig | 1 +
18
2 files changed, 2 insertions(+), 2 deletions(-)
13
2 files changed, 7 insertions(+)
19
14
20
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
15
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
21
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/sve_helper.c
17
--- a/hw/arm/cubieboard.c
23
+++ b/target/arm/sve_helper.c
18
+++ b/hw/arm/cubieboard.c
24
@@ -XXX,XX +XXX,XX @@ static TYPE NAME##_reduce(TYPE *data, float_status *status, uintptr_t n) \
19
@@ -XXX,XX +XXX,XX @@
25
} \
20
#include "hw/boards.h"
26
uint64_t HELPER(NAME)(void *vn, void *vg, void *vs, uint32_t desc) \
21
#include "hw/qdev-properties.h"
27
{ \
22
#include "hw/arm/allwinner-a10.h"
28
- uintptr_t i, oprsz = simd_oprsz(desc), maxsz = simd_maxsz(desc); \
23
+#include "hw/i2c/i2c.h"
29
+ uintptr_t i, oprsz = simd_oprsz(desc), maxsz = simd_data(desc); \
24
30
TYPE data[sizeof(ARMVectorReg) / sizeof(TYPE)]; \
25
static struct arm_boot_info cubieboard_binfo = {
31
for (i = 0; i < oprsz; ) { \
26
.loader_start = AW_A10_SDRAM_BASE,
32
uint16_t pg = *(uint16_t *)(vg + H1_2(i >> 3)); \
27
@@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine)
33
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
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);
37
}
38
39
+ /* Connect AXP 209 */
40
+ i2c = I2C_BUS(qdev_get_child_bus(DEVICE(&a10->i2c0), "i2c"));
41
+ i2c_slave_create_simple(i2c, "axp209_pmu", 0x34);
42
+
43
/* Retrieve SD bus */
44
di = drive_get(IF_SD, 0, 0);
45
blk = di ? blk_by_legacy_dinfo(di) : NULL;
46
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
34
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/translate-sve.c
48
--- a/hw/arm/Kconfig
36
+++ b/target/arm/translate-sve.c
49
+++ b/hw/arm/Kconfig
37
@@ -XXX,XX +XXX,XX @@ static void do_reduce(DisasContext *s, arg_rpr_esz *a,
50
@@ -XXX,XX +XXX,XX @@ config ALLWINNER_A10
38
{
51
select ALLWINNER_A10_DRAMC
39
unsigned vsz = vec_full_reg_size(s);
52
select ALLWINNER_EMAC
40
unsigned p2vsz = pow2ceil(vsz);
53
select ALLWINNER_I2C
41
- TCGv_i32 t_desc = tcg_const_i32(simd_desc(vsz, p2vsz, 0));
54
+ select AXP209_PMU
42
+ TCGv_i32 t_desc = tcg_const_i32(simd_desc(vsz, vsz, p2vsz));
55
select SERIAL
43
TCGv_ptr t_zn, t_pg, status;
56
select UNIMP
44
TCGv_i64 temp;
45
57
46
--
58
--
47
2.20.1
59
2.34.1
48
60
49
61
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
Currently get_naturally_aligned_size() is used by the intel iommu
3
This patch enables copying of SPL from MMC if `-kernel` parameter is not
4
to compute the maximum invalidation range based on @size which is
4
passed when starting QEMU. SPL is copied to SRAM_A.
5
a power of 2 while being aligned with the @start address and less
6
than the maximum range defined by @gaw.
7
5
8
This helper is also useful for other iommu devices (virtio-iommu,
6
The approach is reused from Allwinner H3 implementation.
9
SMMUv3) to make sure IOMMU UNMAP notifiers only are called with
10
power of 2 range sizes.
11
7
12
Let's move this latter into dma-helpers.c and rename it into
8
Tested with Armbian and custom Yocto image.
13
dma_aligned_pow2_mask(). Also rewrite the helper so that it
14
accomodates UINT64_MAX values for the size mask and max mask.
15
It now returns a mask instead of a size. Change the caller.
16
9
17
Signed-off-by: Eric Auger <eric.auger@redhat.com>
10
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
18
Reviewed-by: Peter Xu <peterx@redhat.com>
11
19
Message-id: 20210309102742.30442-3-eric.auger@redhat.com
12
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
13
Message-id: 20221226220303.14420-7-strahinja.p.jankovic@gmail.com
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
15
---
22
include/sysemu/dma.h | 12 ++++++++++++
16
include/hw/arm/allwinner-a10.h | 21 +++++++++++++++++++++
23
hw/i386/intel_iommu.c | 30 +++++++-----------------------
17
hw/arm/allwinner-a10.c | 18 ++++++++++++++++++
24
softmmu/dma-helpers.c | 26 ++++++++++++++++++++++++++
18
hw/arm/cubieboard.c | 5 +++++
25
3 files changed, 45 insertions(+), 23 deletions(-)
19
3 files changed, 44 insertions(+)
26
20
27
diff --git a/include/sysemu/dma.h b/include/sysemu/dma.h
21
diff --git a/include/hw/arm/allwinner-a10.h b/include/hw/arm/allwinner-a10.h
28
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
29
--- a/include/sysemu/dma.h
23
--- a/include/hw/arm/allwinner-a10.h
30
+++ b/include/sysemu/dma.h
24
+++ b/include/hw/arm/allwinner-a10.h
31
@@ -XXX,XX +XXX,XX @@ uint64_t dma_buf_write(uint8_t *ptr, int32_t len, QEMUSGList *sg);
25
@@ -XXX,XX +XXX,XX @@
32
void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie,
26
#include "hw/misc/allwinner-a10-ccm.h"
33
QEMUSGList *sg, enum BlockAcctType type);
27
#include "hw/misc/allwinner-a10-dramc.h"
28
#include "hw/i2c/allwinner-i2c.h"
29
+#include "sysemu/block-backend.h"
30
31
#include "target/arm/cpu.h"
32
#include "qom/object.h"
33
@@ -XXX,XX +XXX,XX @@ struct AwA10State {
34
OHCISysBusState ohci[AW_A10_NUM_USB];
35
};
34
36
35
+/**
37
+/**
36
+ * dma_aligned_pow2_mask: Return the address bit mask of the largest
38
+ * Emulate Boot ROM firmware setup functionality.
37
+ * power of 2 size less or equal than @end - @start + 1, aligned with @start,
38
+ * and bounded by 1 << @max_addr_bits bits.
39
+ *
39
+ *
40
+ * @start: range start address
40
+ * A real Allwinner A10 SoC contains a Boot ROM
41
+ * @end: range end address (greater than @start)
41
+ * which is the first code that runs right after
42
+ * @max_addr_bits: max address bits (<= 64)
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
43
+ */
54
+ */
44
+uint64_t dma_aligned_pow2_mask(uint64_t start, uint64_t end,
55
+void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk);
45
+ int max_addr_bits);
46
+
56
+
47
#endif
57
#endif
48
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
58
diff --git a/hw/arm/allwinner-a10.c b/hw/arm/allwinner-a10.c
49
index XXXXXXX..XXXXXXX 100644
59
index XXXXXXX..XXXXXXX 100644
50
--- a/hw/i386/intel_iommu.c
60
--- a/hw/arm/allwinner-a10.c
51
+++ b/hw/i386/intel_iommu.c
61
+++ b/hw/arm/allwinner-a10.c
52
@@ -XXX,XX +XXX,XX @@
62
@@ -XXX,XX +XXX,XX @@
53
#include "hw/i386/x86-iommu.h"
54
#include "hw/pci-host/q35.h"
55
#include "sysemu/kvm.h"
56
+#include "sysemu/dma.h"
57
#include "sysemu/sysemu.h"
63
#include "sysemu/sysemu.h"
58
#include "hw/i386/apic_internal.h"
64
#include "hw/boards.h"
59
#include "kvm/kvm_i386.h"
65
#include "hw/usb/hcd-ohci.h"
60
@@ -XXX,XX +XXX,XX @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn)
66
+#include "hw/loader.h"
61
return vtd_dev_as;
67
62
}
68
+#define AW_A10_SRAM_A_BASE 0x00000000
63
69
#define AW_A10_DRAMC_BASE 0x01c01000
64
-static uint64_t get_naturally_aligned_size(uint64_t start,
70
#define AW_A10_MMC0_BASE 0x01c0f000
65
- uint64_t size, int gaw)
71
#define AW_A10_CCM_BASE 0x01c20000
66
-{
72
@@ -XXX,XX +XXX,XX @@
67
- uint64_t max_mask = 1ULL << gaw;
73
#define AW_A10_RTC_BASE 0x01c20d00
68
- uint64_t alignment = start ? start & -start : max_mask;
74
#define AW_A10_I2C0_BASE 0x01c2ac00
69
-
75
70
- alignment = MIN(alignment, max_mask);
76
+void allwinner_a10_bootrom_setup(AwA10State *s, BlockBackend *blk)
71
- size = MIN(size, max_mask);
77
+{
72
-
78
+ const int64_t rom_size = 32 * KiB;
73
- if (alignment <= size) {
79
+ g_autofree uint8_t *buffer = g_new0(uint8_t, rom_size);
74
- /* Increase the alignment of start */
75
- return alignment;
76
- } else {
77
- /* Find the largest page mask from size */
78
- return 1ULL << (63 - clz64(size));
79
- }
80
-}
81
-
82
/* Unmap the whole range in the notifier's scope. */
83
static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
84
{
85
@@ -XXX,XX +XXX,XX @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
86
87
while (remain >= VTD_PAGE_SIZE) {
88
IOMMUTLBEvent event;
89
- uint64_t mask = get_naturally_aligned_size(start, remain, s->aw_bits);
90
+ uint64_t mask = dma_aligned_pow2_mask(start, end, s->aw_bits);
91
+ uint64_t size = mask + 1;
92
93
- assert(mask);
94
+ assert(size);
95
96
event.type = IOMMU_NOTIFIER_UNMAP;
97
event.entry.iova = start;
98
- event.entry.addr_mask = mask - 1;
99
+ event.entry.addr_mask = mask;
100
event.entry.target_as = &address_space_memory;
101
event.entry.perm = IOMMU_NONE;
102
/* This field is meaningless for unmap */
103
@@ -XXX,XX +XXX,XX @@ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n)
104
105
memory_region_notify_iommu_one(n, &event);
106
107
- start += mask;
108
- remain -= mask;
109
+ start += size;
110
+ remain -= size;
111
}
112
113
assert(!remain);
114
diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c
115
index XXXXXXX..XXXXXXX 100644
116
--- a/softmmu/dma-helpers.c
117
+++ b/softmmu/dma-helpers.c
118
@@ -XXX,XX +XXX,XX @@ void dma_acct_start(BlockBackend *blk, BlockAcctCookie *cookie,
119
{
120
block_acct_start(blk_get_stats(blk), cookie, sg->size, type);
121
}
122
+
80
+
123
+uint64_t dma_aligned_pow2_mask(uint64_t start, uint64_t end, int max_addr_bits)
81
+ if (blk_pread(blk, 8 * KiB, rom_size, buffer, 0) < 0) {
124
+{
82
+ error_setg(&error_fatal, "%s: failed to read BlockBackend data",
125
+ uint64_t max_mask = UINT64_MAX, addr_mask = end - start;
83
+ __func__);
126
+ uint64_t alignment_mask, size_mask;
84
+ return;
127
+
128
+ if (max_addr_bits != 64) {
129
+ max_mask = (1ULL << max_addr_bits) - 1;
130
+ }
85
+ }
131
+
86
+
132
+ alignment_mask = start ? (start & -start) - 1 : max_mask;
87
+ rom_add_blob("allwinner-a10.bootrom", buffer, rom_size,
133
+ alignment_mask = MIN(alignment_mask, max_mask);
88
+ rom_size, AW_A10_SRAM_A_BASE,
134
+ size_mask = MIN(addr_mask, max_mask);
89
+ NULL, NULL, NULL, NULL, false);
135
+
136
+ if (alignment_mask <= size_mask) {
137
+ /* Increase the alignment of start */
138
+ return alignment_mask;
139
+ } else {
140
+ /* Find the largest page mask from size */
141
+ if (addr_mask == UINT64_MAX) {
142
+ return UINT64_MAX;
143
+ }
144
+ return (1ULL << (63 - clz64(addr_mask + 1))) - 1;
145
+ }
146
+}
90
+}
147
+
91
+
92
static void aw_a10_init(Object *obj)
93
{
94
AwA10State *s = AW_A10(obj);
95
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
96
index XXXXXXX..XXXXXXX 100644
97
--- a/hw/arm/cubieboard.c
98
+++ b/hw/arm/cubieboard.c
99
@@ -XXX,XX +XXX,XX @@ static void cubieboard_init(MachineState *machine)
100
memory_region_add_subregion(get_system_memory(), AW_A10_SDRAM_BASE,
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;
148
--
111
--
149
2.20.1
112
2.34.1
150
151
diff view generated by jsdifflib
1
From: Niek Linnenbank <nieklinnenbank@gmail.com>
1
From: Strahinja Jankovic <strahinjapjankovic@gmail.com>
2
2
3
The image for Armbian 19.11.3 bionic has been removed from the armbian server.
3
Cubieboard now can boot directly from SD card, without the need to pass
4
Without the image as input the test arm_orangepi_bionic_19_11 cannot run.
4
`-kernel` parameter. Update Avocado tests to cover this functionality.
5
5
6
This commit removes the test completely and merges the code of the generic function
6
Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
7
do_test_arm_orangepi_uboot_armbian back with the 20.08 test.
7
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
8
8
Tested-by: Niek Linnenbank <nieklinnenbank@gmail.com>
9
Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
9
Message-id: 20221226220303.14420-8-strahinja.p.jankovic@gmail.com
10
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
11
Message-id: 20210310195820.21950-3-nieklinnenbank@gmail.com
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
13
---
11
---
14
tests/acceptance/boot_linux_console.py | 72 ++++++++------------------
12
tests/avocado/boot_linux_console.py | 47 +++++++++++++++++++++++++++++
15
1 file changed, 23 insertions(+), 49 deletions(-)
13
1 file changed, 47 insertions(+)
16
14
17
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
15
diff --git a/tests/avocado/boot_linux_console.py b/tests/avocado/boot_linux_console.py
18
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
19
--- a/tests/acceptance/boot_linux_console.py
17
--- a/tests/avocado/boot_linux_console.py
20
+++ b/tests/acceptance/boot_linux_console.py
18
+++ b/tests/avocado/boot_linux_console.py
21
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self):
19
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self):
22
# Wait for VM to shut down gracefully
20
'sda')
23
self.vm.wait()
21
# cubieboard's reboot is not functioning; omit reboot test.
24
22
25
- def do_test_arm_orangepi_uboot_armbian(self, image_path):
26
+ @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
27
+ 'Test artifacts fetched from unreliable apt.armbian.com')
28
+ @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
23
+ @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
29
+ def test_arm_orangepi_bionic_20_08(self):
24
+ def test_arm_cubieboard_openwrt_22_03_2(self):
30
+ """
25
+ """
31
+ :avocado: tags=arch:arm
26
+ :avocado: tags=arch:arm
32
+ :avocado: tags=machine:orangepi-pc
27
+ :avocado: tags=machine:cubieboard
33
+ :avocado: tags=device:sd
28
+ :avocado: tags=device:sd
34
+ """
29
+ """
35
+
30
+
36
+ # This test download a 275 MiB compressed image and expand it
31
+ # This test download a 7.5 MiB compressed image and expand it
37
+ # to 1036 MiB, but the underlying filesystem is 1552 MiB...
32
+ # to 126 MiB.
38
+ # As we expand it to 2 GiB we are safe.
33
+ image_url = ('https://downloads.openwrt.org/releases/22.03.2/targets/'
39
+
34
+ 'sunxi/cortexa8/openwrt-22.03.2-sunxi-cortexa8-'
40
+ image_url = ('https://dl.armbian.com/orangepipc/archive/'
35
+ 'cubietech_a10-cubieboard-ext4-sdcard.img.gz')
41
+ 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
36
+ image_hash = ('94b5ecbfbc0b3b56276e5146b899eafa'
42
+ image_hash = ('b4d6775f5673486329e45a0586bf06b6'
37
+ '2ac5dc2d08733d6705af9f144f39f554')
43
+ 'dbe792199fd182ac6b9c7bb6c7d3e6dd')
38
+ image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash,
44
+ image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
45
+ algorithm='sha256')
39
+ algorithm='sha256')
46
+ image_path = archive.extract(image_path_xz, self.workdir)
40
+ image_path = archive.extract(image_path_gz, self.workdir)
47
+ image_pow2ceil_expand(image_path)
41
+ image_pow2ceil_expand(image_path)
48
+
42
+
49
self.vm.set_console()
43
+ self.vm.set_console()
50
self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
44
+ self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw',
51
'-nic', 'user',
45
+ '-nic', 'user',
52
@@ -XXX,XX +XXX,XX @@ def do_test_arm_orangepi_uboot_armbian(self, image_path):
46
+ '-no-reboot')
53
'to <orangepipc>')
47
+ self.vm.launch()
54
self.wait_for_console_pattern('Starting Load Kernel Modules...')
48
+
55
49
+ kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE +
56
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
50
+ 'usbcore.nousb '
57
- 'Test artifacts fetched from unreliable apt.armbian.com')
51
+ 'noreboot')
58
- @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
52
+
59
- @skipUnless(P7ZIP_AVAILABLE, '7z not installed')
53
+ self.wait_for_console_pattern('U-Boot SPL')
60
- def test_arm_orangepi_bionic_19_11(self):
54
+
61
- """
55
+ interrupt_interactive_console_until_pattern(
62
- :avocado: tags=arch:arm
56
+ self, 'Hit any key to stop autoboot:', '=>')
63
- :avocado: tags=machine:orangepi-pc
57
+ exec_command_and_wait_for_pattern(self, "setenv extraargs '" +
64
- :avocado: tags=device:sd
58
+ kernel_command_line + "'", '=>')
65
- """
59
+ exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...');
66
-
60
+
67
- # This test download a 196MB compressed image and expand it to 1GB
61
+ self.wait_for_console_pattern(
68
- image_url = ('https://dl.armbian.com/orangepipc/archive/'
62
+ 'Please press Enter to activate this console.')
69
- 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.7z')
63
+
70
- image_hash = '196a8ffb72b0123d92cea4a070894813d305c71e'
64
+ exec_command_and_wait_for_pattern(self, ' ', 'root@')
71
- image_path_7z = self.fetch_asset(image_url, asset_hash=image_hash)
65
+
72
- image_name = 'Armbian_19.11.3_Orangepipc_bionic_current_5.3.9.img'
66
+ exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo',
73
- image_path = os.path.join(self.workdir, image_name)
67
+ 'Allwinner sun4i/sun5i')
74
- process.run("7z e -o%s %s" % (self.workdir, image_path_7z))
68
+ # cubieboard's reboot is not functioning; omit reboot test.
75
- image_pow2ceil_expand(image_path)
69
+
76
-
70
@skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout')
77
- self.do_test_arm_orangepi_uboot_armbian(image_path)
71
def test_arm_quanta_gsj(self):
78
-
79
- @skipUnless(os.getenv('ARMBIAN_ARTIFACTS_CACHED'),
80
- 'Test artifacts fetched from unreliable apt.armbian.com')
81
- @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
82
- def test_arm_orangepi_bionic_20_08(self):
83
- """
84
- :avocado: tags=arch:arm
85
- :avocado: tags=machine:orangepi-pc
86
- :avocado: tags=device:sd
87
- """
88
-
89
- # This test download a 275 MiB compressed image and expand it
90
- # to 1036 MiB, but the underlying filesystem is 1552 MiB...
91
- # As we expand it to 2 GiB we are safe.
92
-
93
- image_url = ('https://dl.armbian.com/orangepipc/archive/'
94
- 'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
95
- image_hash = ('b4d6775f5673486329e45a0586bf06b6'
96
- 'dbe792199fd182ac6b9c7bb6c7d3e6dd')
97
- image_path_xz = self.fetch_asset(image_url, asset_hash=image_hash,
98
- algorithm='sha256')
99
- image_path = archive.extract(image_path_xz, self.workdir)
100
- image_pow2ceil_expand(image_path)
101
-
102
- self.do_test_arm_orangepi_uboot_armbian(image_path)
103
-
104
@skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited')
105
def test_arm_orangepi_uboot_netbsd9(self):
106
"""
72
"""
107
--
73
--
108
2.20.1
74
2.34.1
109
110
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Richard Henderson <richard.henderson@linaro.org>
2
2
3
Since b64ee454a4a0, all predicate operations should be
3
Don't dereference CPUTLBEntryFull until we verify that
4
using these field macros for predicates.
4
the page is valid. Move the other user-only info field
5
updates after the valid check to match.
5
6
7
Cc: qemu-stable@nongnu.org
8
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1412
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20210309155305.11301-8-richard.henderson@linaro.org
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Message-id: 20230104190056.305143-1-richard.henderson@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
13
---
11
target/arm/sve_helper.c | 4 ++--
14
target/arm/sve_helper.c | 14 +++++++++-----
12
target/arm/translate-sve.c | 7 ++++---
15
1 file changed, 9 insertions(+), 5 deletions(-)
13
2 files changed, 6 insertions(+), 5 deletions(-)
14
16
15
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
17
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sve_helper.c
19
--- a/target/arm/sve_helper.c
18
+++ b/target/arm/sve_helper.c
20
+++ b/target/arm/sve_helper.c
19
@@ -XXX,XX +XXX,XX @@ uint64_t HELPER(sve_cntp)(void *vn, void *vg, uint32_t pred_desc)
21
@@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
20
22
#ifdef CONFIG_USER_ONLY
21
uint32_t HELPER(sve_while)(void *vd, uint32_t count, uint32_t pred_desc)
23
flags = probe_access_flags(env, addr, access_type, mmu_idx, nofault,
22
{
24
&info->host, retaddr);
23
- uintptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
25
- memset(&info->attrs, 0, sizeof(info->attrs));
24
- intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
26
- /* Require both ANON and MTE; see allocation_tag_mem(). */
25
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
27
- info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
26
+ intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
28
#else
27
uint64_t esz_mask = pred_esz_masks[esz];
29
CPUTLBEntryFull *full;
28
ARMPredicateReg *d = vd;
30
flags = probe_access_full(env, addr, access_type, mmu_idx, nofault,
29
uint32_t flags;
31
&info->host, &full, retaddr);
30
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
32
- info->attrs = full->attrs;
31
index XXXXXXX..XXXXXXX 100644
33
- info->tagged = full->pte_attrs == 0xf0;
32
--- a/target/arm/translate-sve.c
34
#endif
33
+++ b/target/arm/translate-sve.c
35
info->flags = flags;
34
@@ -XXX,XX +XXX,XX @@ static bool trans_WHILE(DisasContext *s, arg_WHILE *a)
36
35
TCGv_i64 op0, op1, t0, t1, tmax;
37
@@ -XXX,XX +XXX,XX @@ bool sve_probe_page(SVEHostPage *info, bool nofault, CPUARMState *env,
36
TCGv_i32 t2, t3;
38
return false;
37
TCGv_ptr ptr;
39
}
38
- unsigned desc, vsz = vec_full_reg_size(s);
40
39
+ unsigned vsz = vec_full_reg_size(s);
41
+#ifdef CONFIG_USER_ONLY
40
+ unsigned desc = 0;
42
+ memset(&info->attrs, 0, sizeof(info->attrs));
41
TCGCond cond;
43
+ /* Require both ANON and MTE; see allocation_tag_mem(). */
42
44
+ info->tagged = (flags & PAGE_ANON) && (flags & PAGE_MTE);
43
if (!sve_access_check(s)) {
45
+#else
44
@@ -XXX,XX +XXX,XX @@ static bool trans_WHILE(DisasContext *s, arg_WHILE *a)
46
+ info->attrs = full->attrs;
45
/* Scale elements to bits. */
47
+ info->tagged = full->pte_attrs == 0xf0;
46
tcg_gen_shli_i32(t2, t2, a->esz);
48
+#endif
47
49
+
48
- desc = (vsz / 8) - 2;
50
/* Ensure that info->host[] is relative to addr, not addr + mem_off. */
49
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, a->esz);
51
info->host -= mem_off;
50
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, vsz / 8);
52
return true;
51
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, a->esz);
52
t3 = tcg_const_i32(desc);
53
54
ptr = tcg_temp_new_ptr();
55
--
53
--
56
2.20.1
54
2.34.1
57
55
58
56
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Since b64ee454a4a0, all predicate operations should be
3
Since pxa255_init() must map the device in the system memory,
4
using these field macros for predicates.
4
there is no point in passing get_system_memory() by argument.
5
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Message-id: 20210309155305.11301-5-richard.henderson@linaro.org
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20230109115316.2235-2-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
target/arm/sve_helper.c | 6 +++---
11
include/hw/arm/pxa.h | 2 +-
12
target/arm/translate-sve.c | 7 +++----
12
hw/arm/gumstix.c | 3 +--
13
2 files changed, 6 insertions(+), 7 deletions(-)
13
hw/arm/pxa2xx.c | 4 +++-
14
hw/arm/tosa.c | 2 +-
15
4 files changed, 6 insertions(+), 5 deletions(-)
14
16
15
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
17
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
16
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sve_helper.c
19
--- a/include/hw/arm/pxa.h
18
+++ b/target/arm/sve_helper.c
20
+++ b/include/hw/arm/pxa.h
19
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_compact_d)(void *vd, void *vn, void *vg, uint32_t desc)
21
@@ -XXX,XX +XXX,XX @@ struct PXA2xxI2SState {
20
*/
22
21
int32_t HELPER(sve_last_active_element)(void *vg, uint32_t pred_desc)
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)
22
{
34
{
23
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
35
PXA2xxState *cpu;
24
- intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
36
DriveInfo *dinfo;
25
+ intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8);
37
- MemoryRegion *address_space_mem = get_system_memory();
26
+ intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
38
27
39
uint32_t connex_rom = 0x01000000;
28
- return last_active_element(vg, DIV_ROUND_UP(oprsz, 8), esz);
40
uint32_t connex_ram = 0x04000000;
29
+ return last_active_element(vg, words, esz);
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
51
@@ -XXX,XX +XXX,XX @@
52
#include "qemu/error-report.h"
53
#include "qemu/module.h"
54
#include "qapi/error.h"
55
+#include "exec/address-spaces.h"
56
#include "cpu.h"
57
#include "hw/sysbus.h"
58
#include "migration/vmstate.h"
59
@@ -XXX,XX +XXX,XX @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
30
}
60
}
31
61
32
void HELPER(sve_splice)(void *vd, void *vn, void *vm, void *vg, uint32_t desc)
62
/* Initialise a PXA255 integrated chip (ARM based core). */
33
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
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
34
index XXXXXXX..XXXXXXX 100644
71
index XXXXXXX..XXXXXXX 100644
35
--- a/target/arm/translate-sve.c
72
--- a/hw/arm/tosa.c
36
+++ b/target/arm/translate-sve.c
73
+++ b/hw/arm/tosa.c
37
@@ -XXX,XX +XXX,XX @@ static void find_last_active(DisasContext *s, TCGv_i32 ret, int esz, int pg)
74
@@ -XXX,XX +XXX,XX @@ static void tosa_init(MachineState *machine)
38
*/
75
TC6393xbState *tmio;
39
TCGv_ptr t_p = tcg_temp_new_ptr();
76
DeviceState *scp0, *scp1;
40
TCGv_i32 t_desc;
77
41
- unsigned vsz = pred_full_reg_size(s);
78
- mpu = pxa255_init(address_space_mem, tosa_binfo.ram_size);
42
- unsigned desc;
79
+ mpu = pxa255_init(tosa_binfo.ram_size);
43
+ unsigned desc = 0;
80
44
81
memory_region_init_rom(rom, NULL, "tosa.rom", TOSA_ROM, &error_fatal);
45
- desc = vsz - 2;
82
memory_region_add_subregion(address_space_mem, 0, rom);
46
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, esz);
47
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, pred_full_reg_size(s));
48
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, esz);
49
50
tcg_gen_addi_ptr(t_p, cpu_env, pred_full_reg_offset(s, pg));
51
t_desc = tcg_const_i32(desc);
52
--
83
--
53
2.20.1
84
2.34.1
54
85
55
86
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
As of today, the driver can invalidate a number of pages that is
3
Since pxa270_init() must map the device in the system memory,
4
not a power of 2. However IOTLB unmap notifications and internal
4
there is no point in passing get_system_memory() by argument.
5
IOTLB invalidations work with masks leading to erroneous
6
invalidations.
7
5
8
In case the range is not a power of 2, split invalidations into
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
power of 2 invalidations.
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
8
Message-id: 20230109115316.2235-3-philmd@linaro.org
11
When looking for a single page entry in the vSMMU internal IOTLB,
12
let's make sure that if the entry is not found using a
13
g_hash_table_remove() we iterate over all the entries to find a
14
potential range that overlaps it.
15
16
Signed-off-by: Eric Auger <eric.auger@redhat.com>
17
Message-id: 20210309102742.30442-6-eric.auger@redhat.com
18
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
19
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
20
---
10
---
21
hw/arm/smmu-common.c | 30 ++++++++++++++++++------------
11
include/hw/arm/pxa.h | 3 +--
22
hw/arm/smmuv3.c | 24 ++++++++++++++++++++----
12
hw/arm/gumstix.c | 3 +--
23
2 files changed, 38 insertions(+), 16 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(-)
24
18
25
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
19
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
26
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
27
--- a/hw/arm/smmu-common.c
21
--- a/include/hw/arm/pxa.h
28
+++ b/hw/arm/smmu-common.c
22
+++ b/include/hw/arm/pxa.h
29
@@ -XXX,XX +XXX,XX @@ inline void
23
@@ -XXX,XX +XXX,XX @@ struct PXA2xxI2SState {
30
smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
24
31
uint8_t tg, uint64_t num_pages, uint8_t ttl)
25
# define PA_FMT            "0x%08lx"
26
27
-PXA2xxState *pxa270_init(MemoryRegion *address_space, unsigned int sdram_size,
28
- const char *revision);
29
+PXA2xxState *pxa270_init(unsigned int sdram_size, const char *revision);
30
PXA2xxState *pxa255_init(unsigned int sdram_size);
31
32
#endif /* PXA_H */
33
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
34
index XXXXXXX..XXXXXXX 100644
35
--- a/hw/arm/gumstix.c
36
+++ b/hw/arm/gumstix.c
37
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
32
{
38
{
33
+ /* if tg is not set we use 4KB range invalidation */
39
PXA2xxState *cpu;
34
+ uint8_t granule = tg ? tg * 2 + 10 : 12;
40
DriveInfo *dinfo;
35
+
41
- MemoryRegion *address_space_mem = get_system_memory();
36
if (ttl && (num_pages == 1) && (asid >= 0)) {
42
37
SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl);
43
uint32_t verdex_rom = 0x02000000;
38
44
uint32_t verdex_ram = 0x10000000;
39
- g_hash_table_remove(s->iotlb, &key);
45
40
- } else {
46
- cpu = pxa270_init(address_space_mem, verdex_ram, machine->cpu_type);
41
- /* if tg is not set we use 4KB range invalidation */
47
+ cpu = pxa270_init(verdex_ram, machine->cpu_type);
42
- uint8_t granule = tg ? tg * 2 + 10 : 12;
48
43
-
49
dinfo = drive_get(IF_PFLASH, 0, 0);
44
- SMMUIOTLBPageInvInfo info = {
50
if (!dinfo && !qtest_enabled()) {
45
- .asid = asid, .iova = iova,
51
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
46
- .mask = (num_pages * 1 << granule) - 1};
52
index XXXXXXX..XXXXXXX 100644
47
-
53
--- a/hw/arm/mainstone.c
48
- g_hash_table_foreach_remove(s->iotlb,
54
+++ b/hw/arm/mainstone.c
49
- smmu_hash_remove_by_asid_iova,
55
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info mainstone_binfo = {
50
- &info);
56
.ram_size = 0x04000000,
51
+ if (g_hash_table_remove(s->iotlb, &key)) {
57
};
52
+ return;
58
53
+ }
59
-static void mainstone_common_init(MemoryRegion *address_space_mem,
54
+ /*
60
- MachineState *machine,
55
+ * if the entry is not found, let's see if it does not
61
+static void mainstone_common_init(MachineState *machine,
56
+ * belong to a larger IOTLB entry
62
enum mainstone_model_e model, int arm_id)
57
+ */
63
{
58
}
64
uint32_t sector_len = 256 * 1024;
59
+
65
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
60
+ SMMUIOTLBPageInvInfo info = {
66
MemoryRegion *rom = g_new(MemoryRegion, 1);
61
+ .asid = asid, .iova = iova,
67
62
+ .mask = (num_pages * 1 << granule) - 1};
68
/* Setup CPU & memory */
63
+
69
- mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size,
64
+ g_hash_table_foreach_remove(s->iotlb,
70
- machine->cpu_type);
65
+ smmu_hash_remove_by_asid_iova,
71
+ mpu = pxa270_init(mainstone_binfo.ram_size, machine->cpu_type);
66
+ &info);
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);
67
}
85
}
68
86
69
inline void smmu_iotlb_inv_asid(SMMUState *s, uint16_t asid)
87
static void mainstone2_machine_init(MachineClass *mc)
70
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
88
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
71
index XXXXXXX..XXXXXXX 100644
89
index XXXXXXX..XXXXXXX 100644
72
--- a/hw/arm/smmuv3.c
90
--- a/hw/arm/pxa2xx.c
73
+++ b/hw/arm/smmuv3.c
91
+++ b/hw/arm/pxa2xx.c
74
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
92
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_reset(void *opaque, int line, int level)
75
uint16_t vmid = CMD_VMID(cmd);
76
bool leaf = CMD_LEAF(cmd);
77
uint8_t tg = CMD_TG(cmd);
78
- hwaddr num_pages = 1;
79
+ uint64_t first_page = 0, last_page;
80
+ uint64_t num_pages = 1;
81
int asid = -1;
82
83
if (tg) {
84
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
85
if (type == SMMU_CMD_TLBI_NH_VA) {
86
asid = CMD_ASID(cmd);
87
}
88
- trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, num_pages, ttl, leaf);
89
- smmuv3_inv_notifiers_iova(s, asid, addr, tg, num_pages);
90
- smmu_iotlb_inv_iova(s, asid, addr, tg, num_pages, ttl);
91
+
92
+ /* Split invalidations into ^2 range invalidations */
93
+ last_page = num_pages - 1;
94
+ while (num_pages) {
95
+ uint8_t granule = tg * 2 + 10;
96
+ uint64_t mask, count;
97
+
98
+ mask = dma_aligned_pow2_mask(first_page, last_page, 64 - granule);
99
+ count = mask + 1;
100
+
101
+ trace_smmuv3_s1_range_inval(vmid, asid, addr, tg, count, ttl, leaf);
102
+ smmuv3_inv_notifiers_iova(s, asid, addr, tg, count);
103
+ smmu_iotlb_inv_iova(s, asid, addr, tg, count, ttl);
104
+
105
+ num_pages -= count;
106
+ first_page += count;
107
+ addr += count * BIT_ULL(granule);
108
+ }
109
}
93
}
110
94
111
static int smmuv3_cmdq_consume(SMMUv3State *s)
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)
99
{
100
+ MemoryRegion *address_space = get_system_memory();
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,
112
--
150
--
113
2.20.1
151
2.34.1
114
152
115
153
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
This patch adds the recently implemented MFT device to the NPCM7XX
3
IEC binary prefixes ease code review: the unit is explicit.
4
SoC file.
5
4
6
Reviewed-by: Doug Evans <dje@google.com>
5
Add definitions for RAM / Flash / Flash blocksize.
7
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
6
8
Signed-off-by: Hao Wu <wuhaotsh@google.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
9
Message-id: 20210311180855.149764-4-wuhaotsh@google.com
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
9
Message-id: 20230109115316.2235-4-philmd@linaro.org
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
11
---
13
docs/system/arm/nuvoton.rst | 2 +-
12
hw/arm/collie.c | 16 ++++++++++------
14
include/hw/arm/npcm7xx.h | 2 ++
13
1 file changed, 10 insertions(+), 6 deletions(-)
15
hw/arm/npcm7xx.c | 45 ++++++++++++++++++++++++++++++-------
16
3 files changed, 40 insertions(+), 9 deletions(-)
17
14
18
diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst
15
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
19
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
20
--- a/docs/system/arm/nuvoton.rst
17
--- a/hw/arm/collie.c
21
+++ b/docs/system/arm/nuvoton.rst
18
+++ b/hw/arm/collie.c
22
@@ -XXX,XX +XXX,XX @@ Supported devices
23
* Pulse Width Modulation (PWM)
24
* SMBus controller (SMBF)
25
* Ethernet controller (EMC)
26
+ * Tachometer
27
28
Missing devices
29
---------------
30
@@ -XXX,XX +XXX,XX @@ Missing devices
31
* Peripheral SPI controller (PSPI)
32
* SD/MMC host
33
* PECI interface
34
- * Tachometer
35
* PCI and PCIe root complex and bridges
36
* VDM and MCTP support
37
* Serial I/O expansion
38
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
39
index XXXXXXX..XXXXXXX 100644
40
--- a/include/hw/arm/npcm7xx.h
41
+++ b/include/hw/arm/npcm7xx.h
42
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
43
#include "hw/mem/npcm7xx_mc.h"
20
#include "cpu.h"
44
#include "hw/misc/npcm7xx_clk.h"
21
#include "qom/object.h"
45
#include "hw/misc/npcm7xx_gcr.h"
22
46
+#include "hw/misc/npcm7xx_mft.h"
23
+#define RAM_SIZE (512 * MiB)
47
#include "hw/misc/npcm7xx_pwm.h"
24
+#define FLASH_SIZE (32 * MiB)
48
#include "hw/misc/npcm7xx_rng.h"
25
+#define FLASH_SECTOR_SIZE (64 * KiB)
49
#include "hw/net/npcm7xx_emc.h"
26
+
50
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState {
27
struct CollieMachineState {
51
NPCM7xxTimerCtrlState tim[3];
28
MachineState parent;
52
NPCM7xxADCState adc;
29
53
NPCM7xxPWMState pwm[2];
30
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(CollieMachineState, COLLIE_MACHINE)
54
+ NPCM7xxMFTState mft[8];
31
55
NPCM7xxOTPState key_storage;
32
static struct arm_boot_info collie_binfo = {
56
NPCM7xxOTPState fuse_array;
33
.loader_start = SA_SDCS0,
57
NPCM7xxMCState mc;
34
- .ram_size = 0x20000000,
58
diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
35
+ .ram_size = RAM_SIZE,
59
index XXXXXXX..XXXXXXX 100644
60
--- a/hw/arm/npcm7xx.c
61
+++ b/hw/arm/npcm7xx.c
62
@@ -XXX,XX +XXX,XX @@ enum NPCM7xxInterrupt {
63
NPCM7XX_SMBUS15_IRQ,
64
NPCM7XX_PWM0_IRQ = 93, /* PWM module 0 */
65
NPCM7XX_PWM1_IRQ, /* PWM module 1 */
66
+ NPCM7XX_MFT0_IRQ = 96, /* MFT module 0 */
67
+ NPCM7XX_MFT1_IRQ, /* MFT module 1 */
68
+ NPCM7XX_MFT2_IRQ, /* MFT module 2 */
69
+ NPCM7XX_MFT3_IRQ, /* MFT module 3 */
70
+ NPCM7XX_MFT4_IRQ, /* MFT module 4 */
71
+ NPCM7XX_MFT5_IRQ, /* MFT module 5 */
72
+ NPCM7XX_MFT6_IRQ, /* MFT module 6 */
73
+ NPCM7XX_MFT7_IRQ, /* MFT module 7 */
74
NPCM7XX_EMC2RX_IRQ = 114,
75
NPCM7XX_EMC2TX_IRQ,
76
NPCM7XX_GPIO0_IRQ = 116,
77
@@ -XXX,XX +XXX,XX @@ static const hwaddr npcm7xx_pwm_addr[] = {
78
0xf0104000,
79
};
36
};
80
37
81
+/* Register base address for each MFT Module */
38
static void collie_init(MachineState *machine)
82
+static const hwaddr npcm7xx_mft_addr[] = {
39
@@ -XXX,XX +XXX,XX @@ static void collie_init(MachineState *machine)
83
+ 0xf0180000,
40
memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
84
+ 0xf0181000,
41
85
+ 0xf0182000,
42
dinfo = drive_get(IF_PFLASH, 0, 0);
86
+ 0xf0183000,
43
- pflash_cfi01_register(SA_CS0, "collie.fl1", 0x02000000,
87
+ 0xf0184000,
44
+ pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE,
88
+ 0xf0185000,
45
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
89
+ 0xf0186000,
46
- 64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
90
+ 0xf0187000,
47
+ FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
91
+};
48
92
+
49
dinfo = drive_get(IF_PFLASH, 0, 1);
93
/* Direct memory-mapped access to each SMBus Module. */
50
- pflash_cfi01_register(SA_CS1, "collie.fl2", 0x02000000,
94
static const hwaddr npcm7xx_smbus_addr[] = {
51
+ pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE,
95
0xf0080000,
52
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
96
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_init(Object *obj)
53
- 64 * KiB, 4, 0x00, 0x00, 0x00, 0x00, 0);
97
object_initialize_child(obj, "pwm[*]", &s->pwm[i], TYPE_NPCM7XX_PWM);
54
+ FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
98
}
55
99
56
sysbus_create_simple("scoop", 0x40800000, NULL);
100
+ for (i = 0; i < ARRAY_SIZE(s->mft); i++) {
57
101
+ object_initialize_child(obj, "mft[*]", &s->mft[i], TYPE_NPCM7XX_MFT);
58
@@ -XXX,XX +XXX,XX @@ static void collie_machine_class_init(ObjectClass *oc, void *data)
102
+ }
59
mc->init = collie_init;
103
+
60
mc->ignore_memory_transaction_failures = true;
104
for (i = 0; i < ARRAY_SIZE(s->emc); i++) {
61
mc->default_cpu_type = ARM_CPU_TYPE_NAME("sa1110");
105
object_initialize_child(obj, "emc[*]", &s->emc[i], TYPE_NPCM7XX_EMC);
62
- mc->default_ram_size = 0x20000000;
106
}
63
+ mc->default_ram_size = RAM_SIZE;
107
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
64
mc->default_ram_id = "strongarm.sdram";
108
sysbus_connect_irq(sbd, i, npcm7xx_irq(s, NPCM7XX_PWM0_IRQ + i));
65
}
109
}
66
110
111
+ /* MFT Modules. Cannot fail. */
112
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(npcm7xx_mft_addr) != ARRAY_SIZE(s->mft));
113
+ for (i = 0; i < ARRAY_SIZE(s->mft); i++) {
114
+ SysBusDevice *sbd = SYS_BUS_DEVICE(&s->mft[i]);
115
+
116
+ qdev_connect_clock_in(DEVICE(&s->mft[i]), "clock-in",
117
+ qdev_get_clock_out(DEVICE(&s->clk),
118
+ "apb4-clock"));
119
+ sysbus_realize(sbd, &error_abort);
120
+ sysbus_mmio_map(sbd, 0, npcm7xx_mft_addr[i]);
121
+ sysbus_connect_irq(sbd, 0, npcm7xx_irq(s, NPCM7XX_MFT0_IRQ + i));
122
+ }
123
+
124
/*
125
* EMC Modules. Cannot fail.
126
* The mapping of the device to its netdev backend works as follows:
127
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
128
create_unimplemented_device("npcm7xx.peci", 0xf0100000, 4 * KiB);
129
create_unimplemented_device("npcm7xx.siox[1]", 0xf0101000, 4 * KiB);
130
create_unimplemented_device("npcm7xx.siox[2]", 0xf0102000, 4 * KiB);
131
- create_unimplemented_device("npcm7xx.mft[0]", 0xf0180000, 4 * KiB);
132
- create_unimplemented_device("npcm7xx.mft[1]", 0xf0181000, 4 * KiB);
133
- create_unimplemented_device("npcm7xx.mft[2]", 0xf0182000, 4 * KiB);
134
- create_unimplemented_device("npcm7xx.mft[3]", 0xf0183000, 4 * KiB);
135
- create_unimplemented_device("npcm7xx.mft[4]", 0xf0184000, 4 * KiB);
136
- create_unimplemented_device("npcm7xx.mft[5]", 0xf0185000, 4 * KiB);
137
- create_unimplemented_device("npcm7xx.mft[6]", 0xf0186000, 4 * KiB);
138
- create_unimplemented_device("npcm7xx.mft[7]", 0xf0187000, 4 * KiB);
139
create_unimplemented_device("npcm7xx.pspi1", 0xf0200000, 4 * KiB);
140
create_unimplemented_device("npcm7xx.pspi2", 0xf0201000, 4 * KiB);
141
create_unimplemented_device("npcm7xx.ahbpci", 0xf0400000, 1 * MiB);
142
--
67
--
143
2.20.1
68
2.34.1
144
69
145
70
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
With -Werror=maybe-uninitialized configuration we get
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
../hw/i386/intel_iommu.c: In function ‘vtd_context_device_invalidate’:
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
../hw/i386/intel_iommu.c:1888:10: error: ‘mask’ may be used
5
Message-id: 20230109115316.2235-5-philmd@linaro.org
6
uninitialized in this function [-Werror=maybe-uninitialized]
7
1888 | mask = ~mask;
8
| ~~~~~^~~~~~~
9
10
Add a g_assert_not_reached() to avoid the error.
11
12
Signed-off-by: Eric Auger <eric.auger@redhat.com>
13
Reviewed-by: Peter Xu <peterx@redhat.com>
14
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
15
Message-id: 20210309102742.30442-2-eric.auger@redhat.com
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
17
---
7
---
18
hw/i386/intel_iommu.c | 2 ++
8
hw/arm/collie.c | 17 +++++++----------
19
1 file changed, 2 insertions(+)
9
1 file changed, 7 insertions(+), 10 deletions(-)
20
10
21
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
11
diff --git a/hw/arm/collie.c b/hw/arm/collie.c
22
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/i386/intel_iommu.c
13
--- a/hw/arm/collie.c
24
+++ b/hw/i386/intel_iommu.c
14
+++ b/hw/arm/collie.c
25
@@ -XXX,XX +XXX,XX @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,
15
@@ -XXX,XX +XXX,XX @@ static struct arm_boot_info collie_binfo = {
26
case 3:
16
27
mask = 7; /* Mask bit 2:0 in the SID field */
17
static void collie_init(MachineState *machine)
28
break;
18
{
29
+ default:
19
- DriveInfo *dinfo;
30
+ g_assert_not_reached();
20
MachineClass *mc = MACHINE_GET_CLASS(machine);
31
}
21
CollieMachineState *cms = COLLIE_MACHINE(machine);
32
mask = ~mask;
22
23
@@ -XXX,XX +XXX,XX @@ static void collie_init(MachineState *machine)
24
25
memory_region_add_subregion(get_system_memory(), SA_SDCS0, machine->ram);
26
27
- dinfo = drive_get(IF_PFLASH, 0, 0);
28
- pflash_cfi01_register(SA_CS0, "collie.fl1", FLASH_SIZE,
29
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
30
- FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
31
-
32
- dinfo = drive_get(IF_PFLASH, 0, 1);
33
- pflash_cfi01_register(SA_CS1, "collie.fl2", FLASH_SIZE,
34
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
35
- FLASH_SECTOR_SIZE, 4, 0x00, 0x00, 0x00, 0x00, 0);
36
+ for (unsigned i = 0; i < 2; i++) {
37
+ DriveInfo *dinfo = drive_get(IF_PFLASH, 0, i);
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);
33
45
34
--
46
--
35
2.20.1
47
2.34.1
36
48
37
49
diff view generated by jsdifflib
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
2
3
If the SSECounter link is absent, we set an error message
3
Add a comment describing the Connex uses a Numonyx RC28F128J3F75
4
in sse_timer_realize() but forgot to propagate this error.
4
flash, and the Verdex uses a Micron RC28F256P30TFA.
5
Add the missing 'return'.
6
5
7
Fixes: CID 1450755 (Null pointer dereferences)
6
Correct the Verdex machine description (we model the 'Pro' board).
7
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
8
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
9
Message-id: 20210312001845.1562670-1-f4bug@amsat.org
9
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
10
Message-id: 20230109115316.2235-6-philmd@linaro.org
11
Message-Id: <20200223231044.8003-3-philmd@redhat.com>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
13
---
13
hw/timer/sse-timer.c | 1 +
14
hw/arm/gumstix.c | 6 ++++--
14
1 file changed, 1 insertion(+)
15
1 file changed, 4 insertions(+), 2 deletions(-)
15
16
16
diff --git a/hw/timer/sse-timer.c b/hw/timer/sse-timer.c
17
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
17
index XXXXXXX..XXXXXXX 100644
18
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/timer/sse-timer.c
19
--- a/hw/arm/gumstix.c
19
+++ b/hw/timer/sse-timer.c
20
+++ b/hw/arm/gumstix.c
20
@@ -XXX,XX +XXX,XX @@ static void sse_timer_realize(DeviceState *dev, Error **errp)
21
@@ -XXX,XX +XXX,XX @@
21
22
* Contributions after 2012-01-13 are licensed under the terms of the
22
if (!s->counter) {
23
* GNU GPL, version 2 or (at your option) any later version.
23
error_setg(errp, "counter property was not set");
24
*/
24
+ return;
25
-
26
+
27
/*
28
* Example usage:
29
*
30
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
31
exit(1);
25
}
32
}
26
33
27
s->counter_notifier.notify = sse_timer_counter_callback;
34
+ /* Numonyx RC28F128J3F75 */
35
if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
36
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
37
sector_len, 2, 0, 0, 0, 0, 0)) {
38
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
39
exit(1);
40
}
41
42
+ /* Micron RC28F256P30TFA */
43
if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
44
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
45
sector_len, 2, 0, 0, 0, 0, 0)) {
46
@@ -XXX,XX +XXX,XX @@ static void verdex_class_init(ObjectClass *oc, void *data)
47
{
48
MachineClass *mc = MACHINE_CLASS(oc);
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");
28
--
55
--
29
2.20.1
56
2.34.1
30
57
31
58
diff view generated by jsdifflib
1
We're about to move code from the template header into pxa2xx_lcd.c.
1
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
2
Before doing that, make coding style fixes so checkpatch doesn't
3
complain about the patch which moves the code. This commit fixes
4
missing braces in the SKIP_PIXEL() macro definition and in if()
5
statements.
6
2
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é <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>
7
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
9
Message-id: 20210211141515.8755-8-peter.maydell@linaro.org
10
---
12
---
11
hw/display/pxa2xx_template.h | 47 +++++++++++++++++++++---------------
13
hw/arm/gumstix.c | 27 ++++++++++++++-------------
12
1 file changed, 28 insertions(+), 19 deletions(-)
14
1 file changed, 14 insertions(+), 13 deletions(-)
13
15
14
diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h
16
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
15
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
16
--- a/hw/display/pxa2xx_template.h
18
--- a/hw/arm/gumstix.c
17
+++ b/hw/display/pxa2xx_template.h
19
+++ b/hw/arm/gumstix.c
18
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@
19
* Framebuffer format conversion routines.
20
*/
21
*/
21
22
22
-# define SKIP_PIXEL(to)        to += deststep
23
#include "qemu/osdep.h"
23
+# define SKIP_PIXEL(to) do { to += deststep; } while (0)
24
+#include "qemu/units.h"
24
# define COPY_PIXEL(to, from) \
25
#include "qemu/error-report.h"
25
do { \
26
#include "hw/arm/pxa.h"
26
*(uint32_t *) to = from; \
27
#include "net/net.h"
27
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque,
28
@@ -XXX,XX +XXX,XX @@
28
data >>= 5;
29
#include "sysemu/qtest.h"
29
r = (data & 0x1f) << 3;
30
#include "cpu.h"
30
data >>= 5;
31
31
- if (data & 1)
32
-static const int sector_len = 128 * 1024;
32
+ if (data & 1) {
33
+#define CONNEX_FLASH_SIZE (16 * MiB)
33
SKIP_PIXEL(dest);
34
+#define CONNEX_RAM_SIZE (64 * MiB)
34
- else
35
+
35
+ } else {
36
+#define VERDEX_FLASH_SIZE (32 * MiB)
36
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
37
+#define VERDEX_RAM_SIZE (256 * MiB)
37
+ }
38
+
38
data >>= 1;
39
+#define FLASH_SECTOR_SIZE (128 * KiB)
39
b = (data & 0x1f) << 3;
40
40
data >>= 5;
41
static void connex_init(MachineState *machine)
41
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque,
42
{
42
data >>= 5;
43
PXA2xxState *cpu;
43
r = (data & 0x1f) << 3;
44
DriveInfo *dinfo;
44
data >>= 5;
45
45
- if (data & 1)
46
- uint32_t connex_rom = 0x01000000;
46
+ if (data & 1) {
47
- uint32_t connex_ram = 0x04000000;
47
SKIP_PIXEL(dest);
48
-
48
- else
49
- cpu = pxa255_init(connex_ram);
49
+ } else {
50
+ cpu = pxa255_init(CONNEX_RAM_SIZE);
50
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
51
51
+ }
52
dinfo = drive_get(IF_PFLASH, 0, 0);
52
width -= 2;
53
if (!dinfo && !qtest_enabled()) {
53
src += 4;
54
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
54
}
55
}
55
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19(void *opaque,
56
56
data >>= 6;
57
/* Numonyx RC28F128J3F75 */
57
r = (data & 0x3f) << 2;
58
- if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
58
data >>= 6;
59
+ if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
59
- if (data & 1)
60
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
60
+ if (data & 1) {
61
- sector_len, 2, 0, 0, 0, 0, 0)) {
61
SKIP_PIXEL(dest);
62
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
62
- else
63
error_report("Error registering flash memory");
63
+ } else {
64
exit(1);
64
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
65
+ }
66
width -= 1;
67
src += 4;
68
}
65
}
69
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque,
66
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
70
data[0] >>= 6;
67
PXA2xxState *cpu;
71
r = (data[0] & 0x3f) << 2;
68
DriveInfo *dinfo;
72
data[0] >>= 6;
69
73
- if (data[0] & 1)
70
- uint32_t verdex_rom = 0x02000000;
74
+ if (data[0] & 1) {
71
- uint32_t verdex_ram = 0x10000000;
75
SKIP_PIXEL(dest);
72
-
76
- else
73
- cpu = pxa270_init(verdex_ram, machine->cpu_type);
77
+ } else {
74
+ cpu = pxa270_init(VERDEX_RAM_SIZE, machine->cpu_type);
78
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
75
79
+ }
76
dinfo = drive_get(IF_PFLASH, 0, 0);
80
data[0] >>= 6;
77
if (!dinfo && !qtest_enabled()) {
81
b = (data[0] & 0x3f) << 2;
78
@@ -XXX,XX +XXX,XX @@ static void verdex_init(MachineState *machine)
82
data[0] >>= 6;
83
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque,
84
data[1] >>= 4;
85
r = (data[1] & 0x3f) << 2;
86
data[1] >>= 6;
87
- if (data[1] & 1)
88
+ if (data[1] & 1) {
89
SKIP_PIXEL(dest);
90
- else
91
+ } else {
92
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
93
+ }
94
data[1] >>= 6;
95
b = (data[1] & 0x3f) << 2;
96
data[1] >>= 6;
97
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque,
98
data[1] >>= 6;
99
r = ((data[2] & 0x3) << 6) | (data[1] << 2);
100
data[2] >>= 2;
101
- if (data[2] & 1)
102
+ if (data[2] & 1) {
103
SKIP_PIXEL(dest);
104
- else
105
+ } else {
106
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
107
+ }
108
data[2] >>= 6;
109
b = (data[2] & 0x3f) << 2;
110
data[2] >>= 6;
111
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque,
112
data[2] >>= 6;
113
r = data[2] << 2;
114
data[2] >>= 6;
115
- if (data[2] & 1)
116
+ if (data[2] & 1) {
117
SKIP_PIXEL(dest);
118
- else
119
+ } else {
120
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
121
+ }
122
width -= 4;
123
}
79
}
124
}
80
125
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24t(void *opaque,
81
/* Micron RC28F256P30TFA */
126
data >>= 8;
82
- if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
127
r = data & 0xff;
83
+ if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
128
data >>= 8;
84
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
129
- if (data & 1)
85
- sector_len, 2, 0, 0, 0, 0, 0)) {
130
+ if (data & 1) {
86
+ FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
131
SKIP_PIXEL(dest);
87
error_report("Error registering flash memory");
132
- else
88
exit(1);
133
+ } else {
134
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
135
+ }
136
width -= 1;
137
src += 4;
138
}
139
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line25(void *opaque,
140
data >>= 8;
141
r = data & 0xff;
142
data >>= 8;
143
- if (data & 1)
144
+ if (data & 1) {
145
SKIP_PIXEL(dest);
146
- else
147
+ } else {
148
COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
149
+ }
150
width -= 1;
151
src += 4;
152
}
89
}
153
--
90
--
154
2.20.1
91
2.34.1
155
92
156
93
diff view generated by jsdifflib
1
BITS is always 32, so remove all uses of it from the template header,
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
by dropping the trailing '32' from the draw function names and
3
not constructing the name of rgb_to_pixel32() via the glue() macro.
4
2
3
IEC binary prefixes ease code review: the unit is explicit.
4
5
Add the FLASH_SECTOR_SIZE definition.
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-8-philmd@linaro.org
5
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
7
Message-id: 20210211141515.8755-4-peter.maydell@linaro.org
8
---
11
---
9
hw/display/pl110_template.h | 20 +++----
12
hw/arm/mainstone.c | 18 ++++++++++--------
10
hw/display/pl110.c | 113 ++++++++++++++++++------------------
13
1 file changed, 10 insertions(+), 8 deletions(-)
11
2 files changed, 65 insertions(+), 68 deletions(-)
12
14
13
diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h
15
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/display/pl110_template.h
17
--- a/hw/arm/mainstone.c
16
+++ b/hw/display/pl110_template.h
18
+++ b/hw/arm/mainstone.c
17
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
18
#endif
20
* GNU GPL, version 2 or (at your option) any later version.
19
21
*/
20
#if ORDER == 0
22
#include "qemu/osdep.h"
21
-#define NAME glue(glue(lblp_, BORDER), BITS)
23
+#include "qemu/units.h"
22
+#define NAME glue(lblp_, BORDER)
24
#include "qemu/error-report.h"
23
#ifdef HOST_WORDS_BIGENDIAN
25
#include "qapi/error.h"
24
#define SWAP_WORDS 1
26
#include "hw/arm/pxa.h"
25
#endif
27
@@ -XXX,XX +XXX,XX @@ static const struct keymap map[0xE0] = {
26
#elif ORDER == 1
28
27
-#define NAME glue(glue(bbbp_, BORDER), BITS)
29
enum mainstone_model_e { mainstone };
28
+#define NAME glue(bbbp_, BORDER)
30
29
#ifndef HOST_WORDS_BIGENDIAN
31
-#define MAINSTONE_RAM    0x04000000
30
#define SWAP_WORDS 1
32
-#define MAINSTONE_ROM    0x00800000
31
#endif
33
-#define MAINSTONE_FLASH    0x02000000
32
#else
34
+#define MAINSTONE_RAM_SIZE (64 * MiB)
33
#define SWAP_PIXELS 1
35
+#define MAINSTONE_ROM_SIZE (8 * MiB)
34
-#define NAME glue(glue(lbbp_, BORDER), BITS)
36
+#define MAINSTONE_FLASH_SIZE (32 * MiB)
35
+#define NAME glue(lbbp_, BORDER)
37
36
#ifdef HOST_WORDS_BIGENDIAN
38
static struct arm_boot_info mainstone_binfo = {
37
#define SWAP_WORDS 1
39
.loader_start = PXA2XX_SDRAM_BASE,
38
#endif
40
- .ram_size = 0x04000000,
39
@@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line16_,NAME)(void *opaque, uint8_t *d, const uint8_
41
+ .ram_size = MAINSTONE_RAM_SIZE,
40
MSB = (data & 0x1f) << 3;
41
data >>= 5;
42
#endif
43
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
44
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
45
LSB = (data & 0x1f) << 3;
46
data >>= 5;
47
g = (data & 0x3f) << 2;
48
data >>= 6;
49
MSB = (data & 0x1f) << 3;
50
data >>= 5;
51
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
52
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
53
#undef MSB
54
#undef LSB
55
width -= 2;
56
@@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line32_,NAME)(void *opaque, uint8_t *d, const uint8_
57
g = (data >> 16) & 0xff;
58
MSB = (data >> 8) & 0xff;
59
#endif
60
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
61
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
62
#undef MSB
63
#undef LSB
64
width--;
65
@@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line16_555_,NAME)(void *opaque, uint8_t *d, const ui
66
data >>= 5;
67
MSB = (data & 0x1f) << 3;
68
data >>= 5;
69
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
70
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
71
LSB = (data & 0x1f) << 3;
72
data >>= 5;
73
g = (data & 0x1f) << 3;
74
data >>= 5;
75
MSB = (data & 0x1f) << 3;
76
data >>= 6;
77
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
78
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
79
#undef MSB
80
#undef LSB
81
width -= 2;
82
@@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line12_,NAME)(void *opaque, uint8_t *d, const uint8_
83
data >>= 4;
84
MSB = (data & 0xf) << 4;
85
data >>= 8;
86
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
87
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
88
LSB = (data & 0xf) << 4;
89
data >>= 4;
90
g = (data & 0xf) << 4;
91
data >>= 4;
92
MSB = (data & 0xf) << 4;
93
data >>= 8;
94
- COPY_PIXEL(d, glue(rgb_to_pixel,BITS)(r, g, b));
95
+ COPY_PIXEL(d, rgb_to_pixel32(r, g, b));
96
#undef MSB
97
#undef LSB
98
width -= 2;
99
diff --git a/hw/display/pl110.c b/hw/display/pl110.c
100
index XXXXXXX..XXXXXXX 100644
101
--- a/hw/display/pl110.c
102
+++ b/hw/display/pl110.c
103
@@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = {
104
pl111_id
105
};
42
};
106
43
107
-#define BITS 32
44
+#define FLASH_SECTOR_SIZE (256 * KiB)
108
#define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0)
109
110
#undef RGB
111
@@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = {
112
#include "pl110_template.h"
113
#undef BORDER
114
115
-static drawfn pl110_draw_fn_32[48] = {
116
- pl110_draw_line1_lblp_bgr32,
117
- pl110_draw_line2_lblp_bgr32,
118
- pl110_draw_line4_lblp_bgr32,
119
- pl110_draw_line8_lblp_bgr32,
120
- pl110_draw_line16_555_lblp_bgr32,
121
- pl110_draw_line32_lblp_bgr32,
122
- pl110_draw_line16_lblp_bgr32,
123
- pl110_draw_line12_lblp_bgr32,
124
-
125
- pl110_draw_line1_bbbp_bgr32,
126
- pl110_draw_line2_bbbp_bgr32,
127
- pl110_draw_line4_bbbp_bgr32,
128
- pl110_draw_line8_bbbp_bgr32,
129
- pl110_draw_line16_555_bbbp_bgr32,
130
- pl110_draw_line32_bbbp_bgr32,
131
- pl110_draw_line16_bbbp_bgr32,
132
- pl110_draw_line12_bbbp_bgr32,
133
-
134
- pl110_draw_line1_lbbp_bgr32,
135
- pl110_draw_line2_lbbp_bgr32,
136
- pl110_draw_line4_lbbp_bgr32,
137
- pl110_draw_line8_lbbp_bgr32,
138
- pl110_draw_line16_555_lbbp_bgr32,
139
- pl110_draw_line32_lbbp_bgr32,
140
- pl110_draw_line16_lbbp_bgr32,
141
- pl110_draw_line12_lbbp_bgr32,
142
-
143
- pl110_draw_line1_lblp_rgb32,
144
- pl110_draw_line2_lblp_rgb32,
145
- pl110_draw_line4_lblp_rgb32,
146
- pl110_draw_line8_lblp_rgb32,
147
- pl110_draw_line16_555_lblp_rgb32,
148
- pl110_draw_line32_lblp_rgb32,
149
- pl110_draw_line16_lblp_rgb32,
150
- pl110_draw_line12_lblp_rgb32,
151
-
152
- pl110_draw_line1_bbbp_rgb32,
153
- pl110_draw_line2_bbbp_rgb32,
154
- pl110_draw_line4_bbbp_rgb32,
155
- pl110_draw_line8_bbbp_rgb32,
156
- pl110_draw_line16_555_bbbp_rgb32,
157
- pl110_draw_line32_bbbp_rgb32,
158
- pl110_draw_line16_bbbp_rgb32,
159
- pl110_draw_line12_bbbp_rgb32,
160
-
161
- pl110_draw_line1_lbbp_rgb32,
162
- pl110_draw_line2_lbbp_rgb32,
163
- pl110_draw_line4_lbbp_rgb32,
164
- pl110_draw_line8_lbbp_rgb32,
165
- pl110_draw_line16_555_lbbp_rgb32,
166
- pl110_draw_line32_lbbp_rgb32,
167
- pl110_draw_line16_lbbp_rgb32,
168
- pl110_draw_line12_lbbp_rgb32,
169
-};
170
-
171
-#undef BITS
172
#undef COPY_PIXEL
173
174
+static drawfn pl110_draw_fn_32[48] = {
175
+ pl110_draw_line1_lblp_bgr,
176
+ pl110_draw_line2_lblp_bgr,
177
+ pl110_draw_line4_lblp_bgr,
178
+ pl110_draw_line8_lblp_bgr,
179
+ pl110_draw_line16_555_lblp_bgr,
180
+ pl110_draw_line32_lblp_bgr,
181
+ pl110_draw_line16_lblp_bgr,
182
+ pl110_draw_line12_lblp_bgr,
183
+
45
+
184
+ pl110_draw_line1_bbbp_bgr,
46
static void mainstone_common_init(MachineState *machine,
185
+ pl110_draw_line2_bbbp_bgr,
47
enum mainstone_model_e model, int arm_id)
186
+ pl110_draw_line4_bbbp_bgr,
187
+ pl110_draw_line8_bbbp_bgr,
188
+ pl110_draw_line16_555_bbbp_bgr,
189
+ pl110_draw_line32_bbbp_bgr,
190
+ pl110_draw_line16_bbbp_bgr,
191
+ pl110_draw_line12_bbbp_bgr,
192
+
193
+ pl110_draw_line1_lbbp_bgr,
194
+ pl110_draw_line2_lbbp_bgr,
195
+ pl110_draw_line4_lbbp_bgr,
196
+ pl110_draw_line8_lbbp_bgr,
197
+ pl110_draw_line16_555_lbbp_bgr,
198
+ pl110_draw_line32_lbbp_bgr,
199
+ pl110_draw_line16_lbbp_bgr,
200
+ pl110_draw_line12_lbbp_bgr,
201
+
202
+ pl110_draw_line1_lblp_rgb,
203
+ pl110_draw_line2_lblp_rgb,
204
+ pl110_draw_line4_lblp_rgb,
205
+ pl110_draw_line8_lblp_rgb,
206
+ pl110_draw_line16_555_lblp_rgb,
207
+ pl110_draw_line32_lblp_rgb,
208
+ pl110_draw_line16_lblp_rgb,
209
+ pl110_draw_line12_lblp_rgb,
210
+
211
+ pl110_draw_line1_bbbp_rgb,
212
+ pl110_draw_line2_bbbp_rgb,
213
+ pl110_draw_line4_bbbp_rgb,
214
+ pl110_draw_line8_bbbp_rgb,
215
+ pl110_draw_line16_555_bbbp_rgb,
216
+ pl110_draw_line32_bbbp_rgb,
217
+ pl110_draw_line16_bbbp_rgb,
218
+ pl110_draw_line12_bbbp_rgb,
219
+
220
+ pl110_draw_line1_lbbp_rgb,
221
+ pl110_draw_line2_lbbp_rgb,
222
+ pl110_draw_line4_lbbp_rgb,
223
+ pl110_draw_line8_lbbp_rgb,
224
+ pl110_draw_line16_555_lbbp_rgb,
225
+ pl110_draw_line32_lbbp_rgb,
226
+ pl110_draw_line16_lbbp_rgb,
227
+ pl110_draw_line12_lbbp_rgb,
228
+};
229
230
static int pl110_enabled(PL110State *s)
231
{
48
{
49
- uint32_t sector_len = 256 * 1024;
50
hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
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);
73
}
232
--
74
--
233
2.20.1
75
2.34.1
234
76
235
77
diff view generated by jsdifflib
1
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Connect the support for the Versal Accelerator RAMs (XRAMs).
3
IEC binary prefixes ease code review: the unit is explicit.
4
4
5
Reviewed-by: Luc Michel <luc@lmichel.fr>
5
Add the FLASH_SECTOR_SIZE definition.
6
Acked-by: Alistair Francis <alistair.francis@wdc.com>
6
7
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
Message-id: 20210308224637.2949533-3-edgar.iglesias@gmail.com
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
Message-id: 20230109115316.2235-9-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
11
---
11
docs/system/arm/xlnx-versal-virt.rst | 1 +
12
hw/arm/musicpal.c | 9 ++++++---
12
include/hw/arm/xlnx-versal.h | 13 ++++++++++
13
1 file changed, 6 insertions(+), 3 deletions(-)
13
hw/arm/xlnx-versal.c | 36 ++++++++++++++++++++++++++++
14
3 files changed, 50 insertions(+)
15
14
16
diff --git a/docs/system/arm/xlnx-versal-virt.rst b/docs/system/arm/xlnx-versal-virt.rst
15
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
17
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
18
--- a/docs/system/arm/xlnx-versal-virt.rst
17
--- a/hw/arm/musicpal.c
19
+++ b/docs/system/arm/xlnx-versal-virt.rst
18
+++ b/hw/arm/musicpal.c
20
@@ -XXX,XX +XXX,XX @@ Implemented devices:
21
- 8 ADMA (Xilinx zDMA) channels
22
- 2 SD Controllers
23
- OCM (256KB of On Chip Memory)
24
+- XRAM (4MB of on chip Accelerator RAM)
25
- DDR memory
26
27
QEMU does not yet model any other devices, including the PL and the AI Engine.
28
diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h
29
index XXXXXXX..XXXXXXX 100644
30
--- a/include/hw/arm/xlnx-versal.h
31
+++ b/include/hw/arm/xlnx-versal.h
32
@@ -XXX,XX +XXX,XX @@
33
34
#include "hw/sysbus.h"
35
#include "hw/arm/boot.h"
36
+#include "hw/or-irq.h"
37
#include "hw/sd/sdhci.h"
38
#include "hw/intc/arm_gicv3.h"
39
#include "hw/char/pl011.h"
40
@@ -XXX,XX +XXX,XX @@
41
#include "hw/rtc/xlnx-zynqmp-rtc.h"
42
#include "qom/object.h"
43
#include "hw/usb/xlnx-usb-subsystem.h"
44
+#include "hw/misc/xlnx-versal-xramc.h"
45
46
#define TYPE_XLNX_VERSAL "xlnx-versal"
47
OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL)
48
@@ -XXX,XX +XXX,XX @@ OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL)
49
#define XLNX_VERSAL_NR_GEMS 2
50
#define XLNX_VERSAL_NR_ADMAS 8
51
#define XLNX_VERSAL_NR_SDS 2
52
+#define XLNX_VERSAL_NR_XRAM 4
53
#define XLNX_VERSAL_NR_IRQS 192
54
55
struct Versal {
56
@@ -XXX,XX +XXX,XX @@ struct Versal {
57
XlnxZDMA adma[XLNX_VERSAL_NR_ADMAS];
58
VersalUsb2 usb;
59
} iou;
60
+
61
+ struct {
62
+ qemu_or_irq irq_orgate;
63
+ XlnxXramCtrl ctrl[XLNX_VERSAL_NR_XRAM];
64
+ } xram;
65
} lpd;
66
67
/* The Platform Management Controller subsystem. */
68
@@ -XXX,XX +XXX,XX @@ struct Versal {
69
#define VERSAL_GEM1_IRQ_0 58
70
#define VERSAL_GEM1_WAKE_IRQ_0 59
71
#define VERSAL_ADMA_IRQ_0 60
72
+#define VERSAL_XRAM_IRQ_0 79
73
#define VERSAL_RTC_APB_ERR_IRQ 121
74
#define VERSAL_SD0_IRQ_0 126
75
#define VERSAL_RTC_ALARM_IRQ 142
76
@@ -XXX,XX +XXX,XX @@ struct Versal {
77
#define MM_OCM 0xfffc0000U
78
#define MM_OCM_SIZE 0x40000
79
80
+#define MM_XRAM 0xfe800000
81
+#define MM_XRAMC 0xff8e0000
82
+#define MM_XRAMC_SIZE 0x10000
83
+
84
#define MM_USB2_CTRL_REGS 0xFF9D0000
85
#define MM_USB2_CTRL_REGS_SIZE 0x10000
86
87
diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c
88
index XXXXXXX..XXXXXXX 100644
89
--- a/hw/arm/xlnx-versal.c
90
+++ b/hw/arm/xlnx-versal.c
91
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
92
*/
20
*/
93
21
94
#include "qemu/osdep.h"
22
#include "qemu/osdep.h"
95
+#include "qemu/units.h"
23
+#include "qemu/units.h"
96
#include "qapi/error.h"
24
#include "qapi/error.h"
97
#include "qemu/log.h"
25
#include "cpu.h"
98
#include "qemu/module.h"
26
#include "hw/sysbus.h"
99
@@ -XXX,XX +XXX,XX @@ static void versal_create_rtc(Versal *s, qemu_irq *pic)
27
@@ -XXX,XX +XXX,XX @@ static const TypeInfo musicpal_key_info = {
100
sysbus_connect_irq(sbd, 1, pic[VERSAL_RTC_APB_ERR_IRQ]);
28
.class_init = musicpal_key_class_init,
101
}
29
};
102
30
103
+static void versal_create_xrams(Versal *s, qemu_irq *pic)
31
+#define FLASH_SECTOR_SIZE (64 * KiB)
104
+{
105
+ int nr_xrams = ARRAY_SIZE(s->lpd.xram.ctrl);
106
+ DeviceState *orgate;
107
+ int i;
108
+
32
+
109
+ /* XRAM IRQs get ORed into a single line. */
33
static struct arm_boot_info musicpal_binfo = {
110
+ object_initialize_child(OBJECT(s), "xram-irq-orgate",
34
.loader_start = 0x0,
111
+ &s->lpd.xram.irq_orgate, TYPE_OR_IRQ);
35
.board_id = 0x20e,
112
+ orgate = DEVICE(&s->lpd.xram.irq_orgate);
36
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
113
+ object_property_set_int(OBJECT(orgate),
37
BlockBackend *blk = blk_by_legacy_dinfo(dinfo);
114
+ "num-lines", nr_xrams, &error_fatal);
38
115
+ qdev_realize(orgate, NULL, &error_fatal);
39
flash_size = blk_getlength(blk);
116
+ qdev_connect_gpio_out(orgate, 0, pic[VERSAL_XRAM_IRQ_0]);
40
- if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
117
+
41
- flash_size != 32*1024*1024) {
118
+ for (i = 0; i < ARRAY_SIZE(s->lpd.xram.ctrl); i++) {
42
+ if (flash_size != 8 * MiB && flash_size != 16 * MiB &&
119
+ SysBusDevice *sbd;
43
+ flash_size != 32 * MiB) {
120
+ MemoryRegion *mr;
44
error_report("Invalid flash image size");
121
+
45
exit(1);
122
+ object_initialize_child(OBJECT(s), "xram[*]", &s->lpd.xram.ctrl[i],
46
}
123
+ TYPE_XLNX_XRAM_CTRL);
47
@@ -XXX,XX +XXX,XX @@ static void musicpal_init(MachineState *machine)
124
+ sbd = SYS_BUS_DEVICE(&s->lpd.xram.ctrl[i]);
48
*/
125
+ sysbus_realize(sbd, &error_fatal);
49
pflash_cfi02_register(0x100000000ULL - MP_FLASH_SIZE_MAX,
126
+
50
"musicpal.flash", flash_size,
127
+ mr = sysbus_mmio_get_region(sbd, 0);
51
- blk, 0x10000,
128
+ memory_region_add_subregion(&s->mr_ps,
52
+ blk, FLASH_SECTOR_SIZE,
129
+ MM_XRAMC + i * MM_XRAMC_SIZE, mr);
53
MP_FLASH_SIZE_MAX / flash_size,
130
+ mr = sysbus_mmio_get_region(sbd, 1);
54
2, 0x00BF, 0x236D, 0x0000, 0x0000,
131
+ memory_region_add_subregion(&s->mr_ps, MM_XRAM + i * MiB, mr);
55
0x5555, 0x2AAA, 0);
132
+
133
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(orgate, i));
134
+ }
135
+}
136
+
137
/* This takes the board allocated linear DDR memory and creates aliases
138
* for each split DDR range/aperture on the Versal address map.
139
*/
140
@@ -XXX,XX +XXX,XX @@ static void versal_realize(DeviceState *dev, Error **errp)
141
versal_create_admas(s, pic);
142
versal_create_sds(s, pic);
143
versal_create_rtc(s, pic);
144
+ versal_create_xrams(s, pic);
145
versal_map_ddr(s);
146
versal_unimp(s);
147
148
--
56
--
149
2.20.1
57
2.34.1
150
58
151
59
diff view generated by jsdifflib
1
From: Niek Linnenbank <nieklinnenbank@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The linux kernel 4.20.7 binary for sunxi has been removed from apt.armbian.com:
3
The total_ram_v1/total_ram_v2 definitions were never used.
4
4
5
$ ARMBIAN_ARTIFACTS_CACHED=yes AVOCADO_ALLOW_LARGE_STORAGE=yes avocado --show=app,console run -t machine:orangepi-pc tests/acceptance/boot_linux_console.py
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Fetching asset from tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
...
7
Message-id: 20230109115316.2235-10-philmd@linaro.org
8
(1/6) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_orangepi:
9
CANCEL: Missing asset https://apt.armbian.com/pool/main/l/linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb (0.55 s)
10
11
This commit updates the sunxi kernel to 5.10.16 for the acceptance
12
tests of the orangepi-pc and cubieboard machines.
13
14
Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
15
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
16
Message-id: 20210310195820.21950-5-nieklinnenbank@gmail.com
17
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
18
---
9
---
19
tests/acceptance/boot_linux_console.py | 40 +++++++++++++-------------
10
hw/arm/omap_sx1.c | 2 --
20
tests/acceptance/replay_kernel.py | 8 +++---
11
1 file changed, 2 deletions(-)
21
2 files changed, 24 insertions(+), 24 deletions(-)
22
12
23
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
13
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
24
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
25
--- a/tests/acceptance/boot_linux_console.py
15
--- a/hw/arm/omap_sx1.c
26
+++ b/tests/acceptance/boot_linux_console.py
16
+++ b/hw/arm/omap_sx1.c
27
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self):
17
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps static_ops = {
28
:avocado: tags=machine:cubieboard
18
#define flash0_size    (16 * 1024 * 1024)
29
"""
19
#define flash1_size    ( 8 * 1024 * 1024)
30
deb_url = ('https://apt.armbian.com/pool/main/l/'
20
#define flash2_size    (32 * 1024 * 1024)
31
- 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
21
-#define total_ram_v1    (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE)
32
- deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
22
-#define total_ram_v2    (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)
33
+ 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
23
34
+ deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
24
static struct arm_boot_info sx1_binfo = {
35
deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
25
.loader_start = OMAP_EMIFF_BASE,
36
kernel_path = self.extract_from_deb(deb_path,
37
- '/boot/vmlinuz-4.20.7-sunxi')
38
- dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
39
+ '/boot/vmlinuz-5.10.16-sunxi')
40
+ dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
41
dtb_path = self.extract_from_deb(deb_path, dtb_path)
42
initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
43
'2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
44
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_sata(self):
45
:avocado: tags=machine:cubieboard
46
"""
47
deb_url = ('https://apt.armbian.com/pool/main/l/'
48
- 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
49
- deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
50
+ 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
51
+ deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
52
deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
53
kernel_path = self.extract_from_deb(deb_path,
54
- '/boot/vmlinuz-4.20.7-sunxi')
55
- dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
56
+ '/boot/vmlinuz-5.10.16-sunxi')
57
+ dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
58
dtb_path = self.extract_from_deb(deb_path, dtb_path)
59
rootfs_url = ('https://github.com/groeck/linux-build-test/raw/'
60
'2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
61
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi(self):
62
:avocado: tags=machine:orangepi-pc
63
"""
64
deb_url = ('https://apt.armbian.com/pool/main/l/'
65
- 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
66
- deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
67
+ 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
68
+ deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
69
deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
70
kernel_path = self.extract_from_deb(deb_path,
71
- '/boot/vmlinuz-4.20.7-sunxi')
72
- dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
73
+ '/boot/vmlinuz-5.10.16-sunxi')
74
+ dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
75
dtb_path = self.extract_from_deb(deb_path, dtb_path)
76
77
self.vm.set_console()
78
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_initrd(self):
79
:avocado: tags=machine:orangepi-pc
80
"""
81
deb_url = ('https://apt.armbian.com/pool/main/l/'
82
- 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
83
- deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
84
+ 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
85
+ deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
86
deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
87
kernel_path = self.extract_from_deb(deb_path,
88
- '/boot/vmlinuz-4.20.7-sunxi')
89
- dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
90
+ '/boot/vmlinuz-5.10.16-sunxi')
91
+ dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
92
dtb_path = self.extract_from_deb(deb_path, dtb_path)
93
initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
94
'2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
95
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_sd(self):
96
:avocado: tags=device:sd
97
"""
98
deb_url = ('https://apt.armbian.com/pool/main/l/'
99
- 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
100
- deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
101
+ 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
102
+ deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
103
deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
104
kernel_path = self.extract_from_deb(deb_path,
105
- '/boot/vmlinuz-4.20.7-sunxi')
106
- dtb_path = '/usr/lib/linux-image-dev-sunxi/sun8i-h3-orangepi-pc.dtb'
107
+ '/boot/vmlinuz-5.10.16-sunxi')
108
+ dtb_path = '/usr/lib/linux-image-current-sunxi/sun8i-h3-orangepi-pc.dtb'
109
dtb_path = self.extract_from_deb(deb_path, dtb_path)
110
rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/'
111
'kci-2019.02/armel/base/rootfs.ext2.xz')
112
diff --git a/tests/acceptance/replay_kernel.py b/tests/acceptance/replay_kernel.py
113
index XXXXXXX..XXXXXXX 100644
114
--- a/tests/acceptance/replay_kernel.py
115
+++ b/tests/acceptance/replay_kernel.py
116
@@ -XXX,XX +XXX,XX @@ def test_arm_cubieboard_initrd(self):
117
:avocado: tags=machine:cubieboard
118
"""
119
deb_url = ('https://apt.armbian.com/pool/main/l/'
120
- 'linux-4.20.7-sunxi/linux-image-dev-sunxi_5.75_armhf.deb')
121
- deb_hash = '1334c29c44d984ffa05ed10de8c3361f33d78315'
122
+ 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb')
123
+ deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0'
124
deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash)
125
kernel_path = self.extract_from_deb(deb_path,
126
- '/boot/vmlinuz-4.20.7-sunxi')
127
- dtb_path = '/usr/lib/linux-image-dev-sunxi/sun4i-a10-cubieboard.dtb'
128
+ '/boot/vmlinuz-5.10.16-sunxi')
129
+ dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb'
130
dtb_path = self.extract_from_deb(deb_path, dtb_path)
131
initrd_url = ('https://github.com/groeck/linux-build-test/raw/'
132
'2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/'
133
--
26
--
134
2.20.1
27
2.34.1
135
28
136
29
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
The virt machine already checks KVM_CAP_ARM_VM_IPA_SIZE to get the
3
IEC binary prefixes ease code review: the unit is explicit.
4
upper bound of the IPA size. If that bound is lower than the highest
5
possible GPA for the machine, then QEMU will error out. However, the
6
IPA is set to 40 when the highest GPA is less than or equal to 40,
7
even when KVM may support an IPA limit as low as 32. This means KVM
8
may fail the VM creation unnecessarily. Additionally, 40 is selected
9
with the value 0, which means use the default, and that gets around
10
a check in some versions of KVM, causing a difficult to debug fail.
11
Always use the IPA size that corresponds to the highest possible GPA,
12
unless it's lower than 32, in which case use 32. Also, we must still
13
use 0 when KVM only supports the legacy fixed 40 bit IPA.
14
4
15
Suggested-by: Marc Zyngier <maz@kernel.org>
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
16
Signed-off-by: Andrew Jones <drjones@redhat.com>
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
17
Reviewed-by: Eric Auger <eric.auger@redhat.com>
7
Message-id: 20230109115316.2235-11-philmd@linaro.org
18
Reviewed-by: Marc Zyngier <maz@kernel.org>
19
Message-id: 20210310135218.255205-3-drjones@redhat.com
20
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
21
---
9
---
22
target/arm/kvm_arm.h | 6 ++++--
10
hw/arm/omap_sx1.c | 33 +++++++++++++++++----------------
23
hw/arm/virt.c | 23 ++++++++++++++++-------
11
1 file changed, 17 insertions(+), 16 deletions(-)
24
target/arm/kvm.c | 4 +++-
25
3 files changed, 23 insertions(+), 10 deletions(-)
26
12
27
diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h
13
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
28
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
29
--- a/target/arm/kvm_arm.h
15
--- a/hw/arm/omap_sx1.c
30
+++ b/target/arm/kvm_arm.h
16
+++ b/hw/arm/omap_sx1.c
31
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_sve_supported(void);
17
@@ -XXX,XX +XXX,XX @@
32
/**
18
* with this program; if not, see <http://www.gnu.org/licenses/>.
33
* kvm_arm_get_max_vm_ipa_size:
34
* @ms: Machine state handle
35
+ * @fixed_ipa: True when the IPA limit is fixed at 40. This is the case
36
+ * for legacy KVM.
37
*
38
* Returns the number of bits in the IPA address space supported by KVM
39
*/
19
*/
40
-int kvm_arm_get_max_vm_ipa_size(MachineState *ms);
20
#include "qemu/osdep.h"
41
+int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa);
21
+#include "qemu/units.h"
42
22
#include "qapi/error.h"
43
/**
23
#include "ui/console.h"
44
* kvm_arm_sync_mpstate_to_kvm:
24
#include "hw/arm/omap.h"
45
@@ -XXX,XX +XXX,XX @@ static inline void kvm_arm_add_vcpu_properties(Object *obj)
25
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps static_ops = {
46
g_assert_not_reached();
26
.endianness = DEVICE_NATIVE_ENDIAN,
27
};
28
29
-#define sdram_size    0x02000000
30
-#define sector_size    (128 * 1024)
31
-#define flash0_size    (16 * 1024 * 1024)
32
-#define flash1_size    ( 8 * 1024 * 1024)
33
-#define flash2_size    (32 * 1024 * 1024)
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)
57
}
58
59
if (version == 2) {
60
- flash_size = flash2_size;
61
+ flash_size = FLASH2_SIZE;
62
}
63
64
memory_region_add_subregion(address_space, OMAP_EMIFF_BASE, machine->ram);
65
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
66
if (!pflash_cfi01_register(OMAP_CS0_BASE,
67
"omap_sx1.flash0-1", flash_size,
68
blk_by_legacy_dinfo(dinfo),
69
- sector_size, 4, 0, 0, 0, 0, 0)) {
70
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
71
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
72
fl_idx);
73
}
74
@@ -XXX,XX +XXX,XX @@ static void sx1_init(MachineState *machine, const int version)
75
(dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
76
MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
77
memory_region_init_rom(flash_1, NULL, "omap_sx1.flash1-0",
78
- flash1_size, &error_fatal);
79
+ FLASH1_SIZE, &error_fatal);
80
memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);
81
82
memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val,
83
- "sx1.cs1", OMAP_CS1_SIZE - flash1_size);
84
+ "sx1.cs1", OMAP_CS1_SIZE - FLASH1_SIZE);
85
memory_region_add_subregion(address_space,
86
- OMAP_CS1_BASE + flash1_size, &cs[1]);
87
+ OMAP_CS1_BASE + FLASH1_SIZE, &cs[1]);
88
89
if (!pflash_cfi01_register(OMAP_CS1_BASE,
90
- "omap_sx1.flash1-1", flash1_size,
91
+ "omap_sx1.flash1-1", FLASH1_SIZE,
92
blk_by_legacy_dinfo(dinfo),
93
- sector_size, 4, 0, 0, 0, 0, 0)) {
94
+ SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
95
fprintf(stderr, "qemu: Error registering flash memory %d.\n",
96
fl_idx);
97
}
98
@@ -XXX,XX +XXX,XX @@ static void sx1_machine_v2_class_init(ObjectClass *oc, void *data)
99
mc->init = sx1_init_v2;
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";
47
}
105
}
48
106
49
-static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
107
@@ -XXX,XX +XXX,XX @@ static void sx1_machine_v1_class_init(ObjectClass *oc, void *data)
50
+static inline int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
108
mc->init = sx1_init_v1;
51
{
109
mc->ignore_memory_transaction_failures = true;
52
g_assert_not_reached();
110
mc->default_cpu_type = ARM_CPU_TYPE_NAME("ti925t");
111
- mc->default_ram_size = sdram_size;
112
+ mc->default_ram_size = SDRAM_SIZE;
113
mc->default_ram_id = "omap1.dram";
53
}
114
}
54
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
55
index XXXXXXX..XXXXXXX 100644
56
--- a/hw/arm/virt.c
57
+++ b/hw/arm/virt.c
58
@@ -XXX,XX +XXX,XX @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
59
static int virt_kvm_type(MachineState *ms, const char *type_str)
60
{
61
VirtMachineState *vms = VIRT_MACHINE(ms);
62
- int max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms);
63
- int requested_pa_size;
64
+ int max_vm_pa_size, requested_pa_size;
65
+ bool fixed_ipa;
66
+
67
+ max_vm_pa_size = kvm_arm_get_max_vm_ipa_size(ms, &fixed_ipa);
68
69
/* we freeze the memory map to compute the highest gpa */
70
virt_set_memmap(vms);
71
72
requested_pa_size = 64 - clz64(vms->highest_gpa);
73
74
+ /*
75
+ * KVM requires the IPA size to be at least 32 bits.
76
+ */
77
+ if (requested_pa_size < 32) {
78
+ requested_pa_size = 32;
79
+ }
80
+
81
if (requested_pa_size > max_vm_pa_size) {
82
error_report("-m and ,maxmem option values "
83
"require an IPA range (%d bits) larger than "
84
"the one supported by the host (%d bits)",
85
requested_pa_size, max_vm_pa_size);
86
- exit(1);
87
+ exit(1);
88
}
89
/*
90
- * By default we return 0 which corresponds to an implicit legacy
91
- * 40b IPA setting. Otherwise we return the actual requested PA
92
- * logsize
93
+ * We return the requested PA log size, unless KVM only supports
94
+ * the implicit legacy 40b IPA setting, in which case the kvm_type
95
+ * must be 0.
96
*/
97
- return requested_pa_size > 40 ? requested_pa_size : 0;
98
+ return fixed_ipa ? 0 : requested_pa_size;
99
}
100
101
static void virt_machine_class_init(ObjectClass *oc, void *data)
102
diff --git a/target/arm/kvm.c b/target/arm/kvm.c
103
index XXXXXXX..XXXXXXX 100644
104
--- a/target/arm/kvm.c
105
+++ b/target/arm/kvm.c
106
@@ -XXX,XX +XXX,XX @@ bool kvm_arm_pmu_supported(void)
107
return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3);
108
}
109
110
-int kvm_arm_get_max_vm_ipa_size(MachineState *ms)
111
+int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa)
112
{
113
KVMState *s = KVM_STATE(ms->accelerator);
114
int ret;
115
116
ret = kvm_check_extension(s, KVM_CAP_ARM_VM_IPA_SIZE);
117
+ *fixed_ipa = ret <= 0;
118
+
119
return ret > 0 ? ret : 40;
120
}
121
115
122
--
116
--
123
2.20.1
117
2.34.1
124
118
125
119
diff view generated by jsdifflib
1
The pl110_template.h header has a doubly-nested multiple-include pattern:
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
* pl110.c includes it once for each host bit depth (now always 32)
3
* every time it is included, it includes itself 6 times, to account
4
for multiple guest device pixel and byte orders
5
2
6
Now we only have to deal with 32-bit host bit depths, we can move the
3
IEC binary prefixes ease code review: the unit is explicit.
7
code corresponding to the outer layer of this double-nesting to be
8
directly in pl110.c and reduce the template header to a single layer
9
of nesting.
10
4
5
Add the FLASH_SECTOR_SIZE definition.
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
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
13
Message-id: 20210211141515.8755-3-peter.maydell@linaro.org
14
---
11
---
15
hw/display/pl110_template.h | 100 +-----------------------------------
12
hw/arm/z2.c | 6 ++++--
16
hw/display/pl110.c | 79 ++++++++++++++++++++++++++++
13
1 file changed, 4 insertions(+), 2 deletions(-)
17
2 files changed, 80 insertions(+), 99 deletions(-)
18
14
19
diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h
15
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
20
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
21
--- a/hw/display/pl110_template.h
17
--- a/hw/arm/z2.c
22
+++ b/hw/display/pl110_template.h
18
+++ b/hw/arm/z2.c
23
@@ -XXX,XX +XXX,XX @@
19
@@ -XXX,XX +XXX,XX @@
24
*/
20
*/
25
21
26
#ifndef ORDER
22
#include "qemu/osdep.h"
27
-
23
+#include "qemu/units.h"
28
-#if BITS == 8
24
#include "hw/arm/pxa.h"
29
-#define COPY_PIXEL(to, from) *(to++) = from
25
#include "hw/arm/boot.h"
30
-#elif BITS == 15 || BITS == 16
26
#include "hw/i2c/i2c.h"
31
-#define COPY_PIXEL(to, from) do { *(uint16_t *)to = from; to += 2; } while (0)
27
@@ -XXX,XX +XXX,XX @@ static const TypeInfo aer915_info = {
32
-#elif BITS == 24
28
.class_init = aer915_class_init,
33
-#define COPY_PIXEL(to, from) \
34
- do { \
35
- *(to++) = from; \
36
- *(to++) = (from) >> 8; \
37
- *(to++) = (from) >> 16; \
38
- } while (0)
39
-#elif BITS == 32
40
-#define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0)
41
-#else
42
-#error unknown bit depth
43
+#error "pl110_template.h is only for inclusion by pl110.c"
44
#endif
45
46
-#undef RGB
47
-#define BORDER bgr
48
-#define ORDER 0
49
-#include "pl110_template.h"
50
-#define ORDER 1
51
-#include "pl110_template.h"
52
-#define ORDER 2
53
-#include "pl110_template.h"
54
-#undef BORDER
55
-#define RGB
56
-#define BORDER rgb
57
-#define ORDER 0
58
-#include "pl110_template.h"
59
-#define ORDER 1
60
-#include "pl110_template.h"
61
-#define ORDER 2
62
-#include "pl110_template.h"
63
-#undef BORDER
64
-
65
-static drawfn glue(pl110_draw_fn_,BITS)[48] =
66
-{
67
- glue(pl110_draw_line1_lblp_bgr,BITS),
68
- glue(pl110_draw_line2_lblp_bgr,BITS),
69
- glue(pl110_draw_line4_lblp_bgr,BITS),
70
- glue(pl110_draw_line8_lblp_bgr,BITS),
71
- glue(pl110_draw_line16_555_lblp_bgr,BITS),
72
- glue(pl110_draw_line32_lblp_bgr,BITS),
73
- glue(pl110_draw_line16_lblp_bgr,BITS),
74
- glue(pl110_draw_line12_lblp_bgr,BITS),
75
-
76
- glue(pl110_draw_line1_bbbp_bgr,BITS),
77
- glue(pl110_draw_line2_bbbp_bgr,BITS),
78
- glue(pl110_draw_line4_bbbp_bgr,BITS),
79
- glue(pl110_draw_line8_bbbp_bgr,BITS),
80
- glue(pl110_draw_line16_555_bbbp_bgr,BITS),
81
- glue(pl110_draw_line32_bbbp_bgr,BITS),
82
- glue(pl110_draw_line16_bbbp_bgr,BITS),
83
- glue(pl110_draw_line12_bbbp_bgr,BITS),
84
-
85
- glue(pl110_draw_line1_lbbp_bgr,BITS),
86
- glue(pl110_draw_line2_lbbp_bgr,BITS),
87
- glue(pl110_draw_line4_lbbp_bgr,BITS),
88
- glue(pl110_draw_line8_lbbp_bgr,BITS),
89
- glue(pl110_draw_line16_555_lbbp_bgr,BITS),
90
- glue(pl110_draw_line32_lbbp_bgr,BITS),
91
- glue(pl110_draw_line16_lbbp_bgr,BITS),
92
- glue(pl110_draw_line12_lbbp_bgr,BITS),
93
-
94
- glue(pl110_draw_line1_lblp_rgb,BITS),
95
- glue(pl110_draw_line2_lblp_rgb,BITS),
96
- glue(pl110_draw_line4_lblp_rgb,BITS),
97
- glue(pl110_draw_line8_lblp_rgb,BITS),
98
- glue(pl110_draw_line16_555_lblp_rgb,BITS),
99
- glue(pl110_draw_line32_lblp_rgb,BITS),
100
- glue(pl110_draw_line16_lblp_rgb,BITS),
101
- glue(pl110_draw_line12_lblp_rgb,BITS),
102
-
103
- glue(pl110_draw_line1_bbbp_rgb,BITS),
104
- glue(pl110_draw_line2_bbbp_rgb,BITS),
105
- glue(pl110_draw_line4_bbbp_rgb,BITS),
106
- glue(pl110_draw_line8_bbbp_rgb,BITS),
107
- glue(pl110_draw_line16_555_bbbp_rgb,BITS),
108
- glue(pl110_draw_line32_bbbp_rgb,BITS),
109
- glue(pl110_draw_line16_bbbp_rgb,BITS),
110
- glue(pl110_draw_line12_bbbp_rgb,BITS),
111
-
112
- glue(pl110_draw_line1_lbbp_rgb,BITS),
113
- glue(pl110_draw_line2_lbbp_rgb,BITS),
114
- glue(pl110_draw_line4_lbbp_rgb,BITS),
115
- glue(pl110_draw_line8_lbbp_rgb,BITS),
116
- glue(pl110_draw_line16_555_lbbp_rgb,BITS),
117
- glue(pl110_draw_line32_lbbp_rgb,BITS),
118
- glue(pl110_draw_line16_lbbp_rgb,BITS),
119
- glue(pl110_draw_line12_lbbp_rgb,BITS),
120
-};
121
-
122
-#undef BITS
123
-#undef COPY_PIXEL
124
-
125
-#else
126
-
127
#if ORDER == 0
128
#define NAME glue(glue(lblp_, BORDER), BITS)
129
#ifdef HOST_WORDS_BIGENDIAN
130
@@ -XXX,XX +XXX,XX @@ static void glue(pl110_draw_line12_,NAME)(void *opaque, uint8_t *d, const uint8_
131
#undef NAME
132
#undef SWAP_WORDS
133
#undef ORDER
134
-
135
-#endif
136
diff --git a/hw/display/pl110.c b/hw/display/pl110.c
137
index XXXXXXX..XXXXXXX 100644
138
--- a/hw/display/pl110.c
139
+++ b/hw/display/pl110.c
140
@@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = {
141
};
29
};
142
30
143
#define BITS 32
31
+#define FLASH_SECTOR_SIZE (64 * KiB)
144
+#define COPY_PIXEL(to, from) do { *(uint32_t *)to = from; to += 4; } while (0)
145
+
32
+
146
+#undef RGB
33
static void z2_init(MachineState *machine)
147
+#define BORDER bgr
148
+#define ORDER 0
149
#include "pl110_template.h"
150
+#define ORDER 1
151
+#include "pl110_template.h"
152
+#define ORDER 2
153
+#include "pl110_template.h"
154
+#undef BORDER
155
+#define RGB
156
+#define BORDER rgb
157
+#define ORDER 0
158
+#include "pl110_template.h"
159
+#define ORDER 1
160
+#include "pl110_template.h"
161
+#define ORDER 2
162
+#include "pl110_template.h"
163
+#undef BORDER
164
+
165
+static drawfn pl110_draw_fn_32[48] = {
166
+ pl110_draw_line1_lblp_bgr32,
167
+ pl110_draw_line2_lblp_bgr32,
168
+ pl110_draw_line4_lblp_bgr32,
169
+ pl110_draw_line8_lblp_bgr32,
170
+ pl110_draw_line16_555_lblp_bgr32,
171
+ pl110_draw_line32_lblp_bgr32,
172
+ pl110_draw_line16_lblp_bgr32,
173
+ pl110_draw_line12_lblp_bgr32,
174
+
175
+ pl110_draw_line1_bbbp_bgr32,
176
+ pl110_draw_line2_bbbp_bgr32,
177
+ pl110_draw_line4_bbbp_bgr32,
178
+ pl110_draw_line8_bbbp_bgr32,
179
+ pl110_draw_line16_555_bbbp_bgr32,
180
+ pl110_draw_line32_bbbp_bgr32,
181
+ pl110_draw_line16_bbbp_bgr32,
182
+ pl110_draw_line12_bbbp_bgr32,
183
+
184
+ pl110_draw_line1_lbbp_bgr32,
185
+ pl110_draw_line2_lbbp_bgr32,
186
+ pl110_draw_line4_lbbp_bgr32,
187
+ pl110_draw_line8_lbbp_bgr32,
188
+ pl110_draw_line16_555_lbbp_bgr32,
189
+ pl110_draw_line32_lbbp_bgr32,
190
+ pl110_draw_line16_lbbp_bgr32,
191
+ pl110_draw_line12_lbbp_bgr32,
192
+
193
+ pl110_draw_line1_lblp_rgb32,
194
+ pl110_draw_line2_lblp_rgb32,
195
+ pl110_draw_line4_lblp_rgb32,
196
+ pl110_draw_line8_lblp_rgb32,
197
+ pl110_draw_line16_555_lblp_rgb32,
198
+ pl110_draw_line32_lblp_rgb32,
199
+ pl110_draw_line16_lblp_rgb32,
200
+ pl110_draw_line12_lblp_rgb32,
201
+
202
+ pl110_draw_line1_bbbp_rgb32,
203
+ pl110_draw_line2_bbbp_rgb32,
204
+ pl110_draw_line4_bbbp_rgb32,
205
+ pl110_draw_line8_bbbp_rgb32,
206
+ pl110_draw_line16_555_bbbp_rgb32,
207
+ pl110_draw_line32_bbbp_rgb32,
208
+ pl110_draw_line16_bbbp_rgb32,
209
+ pl110_draw_line12_bbbp_rgb32,
210
+
211
+ pl110_draw_line1_lbbp_rgb32,
212
+ pl110_draw_line2_lbbp_rgb32,
213
+ pl110_draw_line4_lbbp_rgb32,
214
+ pl110_draw_line8_lbbp_rgb32,
215
+ pl110_draw_line16_555_lbbp_rgb32,
216
+ pl110_draw_line32_lbbp_rgb32,
217
+ pl110_draw_line16_lbbp_rgb32,
218
+ pl110_draw_line12_lbbp_rgb32,
219
+};
220
+
221
+#undef BITS
222
+#undef COPY_PIXEL
223
+
224
225
static int pl110_enabled(PL110State *s)
226
{
34
{
35
- uint32_t sector_len = 0x10000;
36
PXA2xxState *mpu;
37
DriveInfo *dinfo;
38
void *z2_lcd;
39
@@ -XXX,XX +XXX,XX @@ static void z2_init(MachineState *machine)
40
dinfo = drive_get(IF_PFLASH, 0, 0);
41
if (!pflash_cfi01_register(Z2_FLASH_BASE, "z2.flash0", Z2_FLASH_SIZE,
42
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
43
- sector_len, 4, 0, 0, 0, 0, 0)) {
44
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
45
error_report("Error registering flash memory");
46
exit(1);
47
}
227
--
48
--
228
2.20.1
49
2.34.1
229
50
230
51
diff view generated by jsdifflib
1
For a long time now the UI layer has guaranteed that the console
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
surface is always 32 bits per pixel. Remove the legacy dead
3
code from the pl110 display device which was handling the
4
possibility that the console surface was some other format.
5
2
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.
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-13-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
8
Message-id: 20210211141515.8755-2-peter.maydell@linaro.org
9
---
13
---
10
hw/display/pl110.c | 53 +++++++---------------------------------------
14
hw/arm/vexpress.c | 10 +---------
11
1 file changed, 8 insertions(+), 45 deletions(-)
15
1 file changed, 1 insertion(+), 9 deletions(-)
12
16
13
diff --git a/hw/display/pl110.c b/hw/display/pl110.c
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/hw/display/pl110.c
19
--- a/hw/arm/vexpress.c
16
+++ b/hw/display/pl110.c
20
+++ b/hw/arm/vexpress.c
17
@@ -XXX,XX +XXX,XX @@ static const unsigned char *idregs[] = {
21
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
18
pl111_id
22
dinfo = drive_get(IF_PFLASH, 0, 0);
19
};
23
pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0",
20
24
dinfo);
21
-#define BITS 8
25
- if (!pflash0) {
22
-#include "pl110_template.h"
26
- error_report("vexpress: error registering flash 0");
23
-#define BITS 15
24
-#include "pl110_template.h"
25
-#define BITS 16
26
-#include "pl110_template.h"
27
-#define BITS 24
28
-#include "pl110_template.h"
29
#define BITS 32
30
#include "pl110_template.h"
31
32
@@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque)
33
PL110State *s = (PL110State *)opaque;
34
SysBusDevice *sbd;
35
DisplaySurface *surface = qemu_console_surface(s->con);
36
- drawfn* fntable;
37
drawfn fn;
38
- int dest_width;
39
int src_width;
40
int bpp_offset;
41
int first;
42
@@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque)
43
44
sbd = SYS_BUS_DEVICE(s);
45
46
- switch (surface_bits_per_pixel(surface)) {
47
- case 0:
48
- return;
49
- case 8:
50
- fntable = pl110_draw_fn_8;
51
- dest_width = 1;
52
- break;
53
- case 15:
54
- fntable = pl110_draw_fn_15;
55
- dest_width = 2;
56
- break;
57
- case 16:
58
- fntable = pl110_draw_fn_16;
59
- dest_width = 2;
60
- break;
61
- case 24:
62
- fntable = pl110_draw_fn_24;
63
- dest_width = 3;
64
- break;
65
- case 32:
66
- fntable = pl110_draw_fn_32;
67
- dest_width = 4;
68
- break;
69
- default:
70
- fprintf(stderr, "pl110: Bad color depth\n");
71
- exit(1);
27
- exit(1);
72
- }
28
- }
73
if (s->cr & PL110_CR_BGR)
29
74
bpp_offset = 0;
30
if (map[VE_NORFLASHALIAS] != -1) {
75
else
31
/* Map flash 0 as an alias into low memory */
76
@@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque)
32
@@ -XXX,XX +XXX,XX @@ static void vexpress_common_init(MachineState *machine)
77
}
78
}
33
}
79
34
80
- if (s->cr & PL110_CR_BEBO)
35
dinfo = drive_get(IF_PFLASH, 0, 1);
81
- fn = fntable[s->bpp + 8 + bpp_offset];
36
- if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1",
82
- else if (s->cr & PL110_CR_BEPO)
37
- dinfo)) {
83
- fn = fntable[s->bpp + 16 + bpp_offset];
38
- error_report("vexpress: error registering flash 1");
84
- else
39
- exit(1);
85
- fn = fntable[s->bpp + bpp_offset];
40
- }
86
+ if (s->cr & PL110_CR_BEBO) {
41
+ ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1", dinfo);
87
+ fn = pl110_draw_fn_32[s->bpp + 8 + bpp_offset];
42
88
+ } else if (s->cr & PL110_CR_BEPO) {
43
sram_size = 0x2000000;
89
+ fn = pl110_draw_fn_32[s->bpp + 16 + bpp_offset];
44
memory_region_init_ram(sram, NULL, "vexpress.sram", sram_size,
90
+ } else {
91
+ fn = pl110_draw_fn_32[s->bpp + bpp_offset];
92
+ }
93
94
src_width = s->cols;
95
switch (s->bpp) {
96
@@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque)
97
src_width <<= 2;
98
break;
99
}
100
- dest_width *= s->cols;
101
first = 0;
102
if (s->invalidate) {
103
framebuffer_update_memory_section(&s->fbsection,
104
@@ -XXX,XX +XXX,XX @@ static void pl110_update_display(void *opaque)
105
106
framebuffer_update_display(surface, &s->fbsection,
107
s->cols, s->rows,
108
- src_width, dest_width, 0,
109
+ src_width, s->cols * 4, 0,
110
s->invalidate,
111
fn, s->palette,
112
&first, &last);
113
--
45
--
114
2.20.1
46
2.34.1
115
47
116
48
diff view generated by jsdifflib
1
From: Andrew Jones <drjones@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Prior to commit f2ce39b4f067 a MachineClass kvm_type method
3
Since its QOM'ification in commit 368a354f02 ("pflash_cfi0x:
4
only needed to be registered to ensure it would be executed.
4
QOMified") the pflash_cfi01_register() function does not fail.
5
With commit f2ce39b4f067 a kvm-type machine property must also
6
be specified. hw/arm/virt relies on the kvm_type method to pass
7
its selected IPA limit to KVM, but this is not exposed as a
8
machine property. Restore the previous functionality of invoking
9
kvm_type when it's present.
10
5
11
Fixes: f2ce39b4f067 ("vl: make qemu_get_machine_opts static")
6
This call was later converted with a script to use &error_fatal,
12
Signed-off-by: Andrew Jones <drjones@redhat.com>
7
still unable to fail. Remove the unreachable code.
13
Reviewed-by: Eric Auger <eric.auger@redhat.com>
8
14
Message-id: 20210310135218.255205-2-drjones@redhat.com
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
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
13
---
17
include/hw/boards.h | 1 +
14
hw/arm/gumstix.c | 18 ++++++------------
18
accel/kvm/kvm-all.c | 2 ++
15
hw/arm/mainstone.c | 13 +++++--------
19
2 files changed, 3 insertions(+)
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(-)
20
20
21
diff --git a/include/hw/boards.h b/include/hw/boards.h
21
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
22
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/boards.h
23
--- a/hw/arm/gumstix.c
24
+++ b/include/hw/boards.h
24
+++ b/hw/arm/gumstix.c
25
@@ -XXX,XX +XXX,XX @@ typedef struct {
25
@@ -XXX,XX +XXX,XX @@ static void connex_init(MachineState *machine)
26
* @kvm_type:
26
}
27
* Return the type of KVM corresponding to the kvm-type string option or
27
28
* computed based on other criteria such as the host kernel capabilities.
28
/* Numonyx RC28F128J3F75 */
29
+ * kvm-type may be NULL if it is not needed.
29
- if (!pflash_cfi01_register(0x00000000, "connext.rom", CONNEX_FLASH_SIZE,
30
* @numa_mem_supported:
30
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
31
* true if '--numa node.mem' option is supported and false otherwise
31
- FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
32
* @smp_parse:
32
- error_report("Error registering flash memory");
33
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
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)
42
}
43
44
/* Micron RC28F256P30TFA */
45
- if (!pflash_cfi01_register(0x00000000, "verdex.rom", VERDEX_FLASH_SIZE,
46
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
47
- FLASH_SECTOR_SIZE, 2, 0, 0, 0, 0, 0)) {
48
- error_report("Error registering flash memory");
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
34
index XXXXXXX..XXXXXXX 100644
58
index XXXXXXX..XXXXXXX 100644
35
--- a/accel/kvm/kvm-all.c
59
--- a/hw/arm/mainstone.c
36
+++ b/accel/kvm/kvm-all.c
60
+++ b/hw/arm/mainstone.c
37
@@ -XXX,XX +XXX,XX @@ static int kvm_init(MachineState *ms)
61
@@ -XXX,XX +XXX,XX @@ static void mainstone_common_init(MachineState *machine,
38
"kvm-type",
62
/* There are two 32MiB flash devices on the board */
39
&error_abort);
63
for (i = 0; i < 2; i ++) {
40
type = mc->kvm_type(ms, kvm_type);
64
dinfo = drive_get(IF_PFLASH, 0, i);
41
+ } else if (mc->kvm_type) {
65
- if (!pflash_cfi01_register(mainstone_flash_base[i],
42
+ type = mc->kvm_type(ms, NULL);
66
- i ? "mainstone.flash1" : "mainstone.flash0",
67
- MAINSTONE_FLASH_SIZE,
68
- dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
69
- FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0)) {
70
- error_report("Error registering flash memory");
71
- exit(1);
72
- }
73
+ pflash_cfi01_register(mainstone_flash_base[i],
74
+ i ? "mainstone.flash1" : "mainstone.flash0",
75
+ MAINSTONE_FLASH_SIZE,
76
+ dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
77
+ FLASH_SECTOR_SIZE, 4, 0, 0, 0, 0, 0);
43
}
78
}
44
79
45
do {
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);
46
--
161
--
47
2.20.1
162
2.34.1
48
163
49
164
diff view generated by jsdifflib
1
From: Niek Linnenbank <nieklinnenbank@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Update the download URL of the Armbian 20.08 Bionic image for
3
To avoid forward-declaring PXA2xxI2CState, declare
4
test_arm_orangepi_bionic_20_08 of the orangepi-pc machine.
4
PXA2XX_I2C before its use in pxa2xx_i2c_init() prototype.
5
5
6
The archive.armbian.com URL contains more images and should keep stable
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
for a longer period of time than dl.armbian.com.
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
8
Message-id: 20230109140306.23161-2-philmd@linaro.org
9
Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
10
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
11
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Reviewed-by: Willian Rampazzo <willianr@redhat.com>
13
Message-id: 20210310195820.21950-4-nieklinnenbank@gmail.com
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
10
---
16
tests/acceptance/boot_linux_console.py | 2 +-
11
include/hw/arm/pxa.h | 6 +++---
17
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 3 insertions(+), 3 deletions(-)
18
13
19
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
14
diff --git a/include/hw/arm/pxa.h b/include/hw/arm/pxa.h
20
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
21
--- a/tests/acceptance/boot_linux_console.py
16
--- a/include/hw/arm/pxa.h
22
+++ b/tests/acceptance/boot_linux_console.py
17
+++ b/include/hw/arm/pxa.h
23
@@ -XXX,XX +XXX,XX @@ def test_arm_orangepi_bionic_20_08(self):
18
@@ -XXX,XX +XXX,XX @@ void pxa27x_register_keypad(PXA2xxKeyPadState *kp,
24
# to 1036 MiB, but the underlying filesystem is 1552 MiB...
19
const struct keymap *map, int size);
25
# As we expand it to 2 GiB we are safe.
20
26
21
/* pxa2xx.c */
27
- image_url = ('https://dl.armbian.com/orangepipc/archive/'
22
-typedef struct PXA2xxI2CState PXA2xxI2CState;
28
+ image_url = ('https://archive.armbian.com/orangepipc/archive/'
23
+#define TYPE_PXA2XX_I2C "pxa2xx_i2c"
29
'Armbian_20.08.1_Orangepipc_bionic_current_5.8.5.img.xz')
24
+OBJECT_DECLARE_SIMPLE_TYPE(PXA2xxI2CState, PXA2XX_I2C)
30
image_hash = ('b4d6775f5673486329e45a0586bf06b6'
25
+
31
'dbe792199fd182ac6b9c7bb6c7d3e6dd')
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)
32
--
36
--
33
2.20.1
37
2.34.1
34
38
35
39
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Since b64ee454a4a0, all predicate operations should be
3
Add a local 'struct omap_gpif_s *' variable to improve readability.
4
using these field macros for predicates.
4
(This also eases next commit conversion).
5
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
7
Message-id: 20210309155305.11301-7-richard.henderson@linaro.org
7
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
8
Message-id: 20230109140306.23161-3-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
10
---
11
target/arm/sve_helper.c | 6 +++---
11
hw/gpio/omap_gpio.c | 3 ++-
12
target/arm/translate-sve.c | 6 +++---
12
1 file changed, 2 insertions(+), 1 deletion(-)
13
2 files changed, 6 insertions(+), 6 deletions(-)
14
13
15
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
14
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
16
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sve_helper.c
16
--- a/hw/gpio/omap_gpio.c
18
+++ b/target/arm/sve_helper.c
17
+++ b/hw/gpio/omap_gpio.c
19
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkns)(void *vd, void *vn, void *vg, uint32_t pred_desc)
18
@@ -XXX,XX +XXX,XX @@ struct omap_gpif_s {
20
19
/* General-Purpose I/O of OMAP1 */
21
uint64_t HELPER(sve_cntp)(void *vn, void *vg, uint32_t pred_desc)
20
static void omap_gpio_set(void *opaque, int line, int level)
22
{
21
{
23
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
22
- struct omap_gpio_s *s = &((struct omap_gpif_s *) opaque)->omap1;
24
- intptr_t esz = extract32(pred_desc, SIMD_DATA_SHIFT, 2);
23
+ struct omap_gpif_s *p = opaque;
25
+ intptr_t words = DIV_ROUND_UP(FIELD_EX32(pred_desc, PREDDESC, OPRSZ), 8);
24
+ struct omap_gpio_s *s = &p->omap1;
26
+ intptr_t esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
25
uint16_t prev = s->inputs;
27
uint64_t *n = vn, *g = vg, sum = 0, mask = pred_esz_masks[esz];
26
28
intptr_t i;
27
if (level)
29
30
- for (i = 0; i < DIV_ROUND_UP(oprsz, 8); ++i) {
31
+ for (i = 0; i < words; ++i) {
32
uint64_t t = n[i] & g[i] & mask;
33
sum += ctpop64(t);
34
}
35
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
36
index XXXXXXX..XXXXXXX 100644
37
--- a/target/arm/translate-sve.c
38
+++ b/target/arm/translate-sve.c
39
@@ -XXX,XX +XXX,XX @@ static void do_cntp(DisasContext *s, TCGv_i64 val, int esz, int pn, int pg)
40
} else {
41
TCGv_ptr t_pn = tcg_temp_new_ptr();
42
TCGv_ptr t_pg = tcg_temp_new_ptr();
43
- unsigned desc;
44
+ unsigned desc = 0;
45
TCGv_i32 t_desc;
46
47
- desc = psz - 2;
48
- desc = deposit32(desc, SIMD_DATA_SHIFT, 2, esz);
49
+ desc = FIELD_DP32(desc, PREDDESC, OPRSZ, psz);
50
+ desc = FIELD_DP32(desc, PREDDESC, ESZ, esz);
51
52
tcg_gen_addi_ptr(t_pn, cpu_env, pred_full_reg_offset(s, pn));
53
tcg_gen_addi_ptr(t_pg, cpu_env, pred_full_reg_offset(s, pg));
54
--
28
--
55
2.20.1
29
2.34.1
56
30
57
31
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
This patch adds GPIOs in NPCM7xx PWM module for its duty values.
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
The purpose of this is to connect it to the MFT module to provide
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
an input for measuring a PWM fan's RPM. Each PWM module has
5
Message-id: 20230109140306.23161-4-philmd@linaro.org
6
NPCM7XX_PWM_PER_MODULE of GPIOs, each one corresponds to
7
one PWM instance and can connect to multiple fan instances in MFT.
8
9
Reviewed-by: Doug Evans <dje@google.com>
10
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
11
Signed-off-by: Hao Wu <wuhaotsh@google.com>
12
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Message-id: 20210311180855.149764-2-wuhaotsh@google.com
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
15
---
7
---
16
include/hw/misc/npcm7xx_pwm.h | 4 +++-
8
hw/arm/omap1.c | 115 ++++++++++++++++++--------------------
17
hw/misc/npcm7xx_pwm.c | 4 ++++
9
hw/arm/omap2.c | 40 ++++++-------
18
2 files changed, 7 insertions(+), 1 deletion(-)
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(-)
19
27
20
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
28
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
21
index XXXXXXX..XXXXXXX 100644
29
index XXXXXXX..XXXXXXX 100644
22
--- a/include/hw/misc/npcm7xx_pwm.h
30
--- a/hw/arm/omap1.c
23
+++ b/include/hw/misc/npcm7xx_pwm.h
31
+++ b/hw/arm/omap1.c
24
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxPWM {
32
@@ -XXX,XX +XXX,XX @@ static void omap_timer_fire(void *opaque)
25
* @iomem: Memory region through which registers are accessed.
33
26
* @clock: The PWM clock.
34
static void omap_timer_tick(void *opaque)
27
* @pwm: The PWM channels owned by this module.
35
{
28
+ * @duty_gpio_out: The duty cycle of each PWM channels as a output GPIO.
36
- struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque;
29
* @ppr: The prescaler register.
37
+ struct omap_mpu_timer_s *timer = opaque;
30
* @csr: The clock selector register.
38
31
* @pcr: The control register.
39
omap_timer_sync(timer);
32
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxPWMState {
40
omap_timer_fire(timer);
33
MemoryRegion iomem;
41
@@ -XXX,XX +XXX,XX @@ static void omap_timer_tick(void *opaque)
34
42
35
Clock *clock;
43
static void omap_timer_clk_update(void *opaque, int line, int on)
36
- NPCM7xxPWM pwm[NPCM7XX_PWM_PER_MODULE];
44
{
37
+ NPCM7xxPWM pwm[NPCM7XX_PWM_PER_MODULE];
45
- struct omap_mpu_timer_s *timer = (struct omap_mpu_timer_s *) opaque;
38
+ qemu_irq duty_gpio_out[NPCM7XX_PWM_PER_MODULE];
46
+ struct omap_mpu_timer_s *timer = opaque;
39
47
40
uint32_t ppr;
48
omap_timer_sync(timer);
41
uint32_t csr;
49
timer->rate = on ? omap_clk_getrate(timer->clk) : 0;
42
diff --git a/hw/misc/npcm7xx_pwm.c b/hw/misc/npcm7xx_pwm.c
50
@@ -XXX,XX +XXX,XX @@ static void omap_timer_clk_setup(struct omap_mpu_timer_s *timer)
43
index XXXXXXX..XXXXXXX 100644
51
static uint64_t omap_mpu_timer_read(void *opaque, hwaddr addr,
44
--- a/hw/misc/npcm7xx_pwm.c
52
unsigned size)
45
+++ b/hw/misc/npcm7xx_pwm.c
53
{
46
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_update_duty(NPCM7xxPWM *p)
54
- struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque;
47
trace_npcm7xx_pwm_update_duty(DEVICE(p->module)->canonical_path,
55
+ struct omap_mpu_timer_s *s = opaque;
48
p->index, p->duty, duty);
56
49
p->duty = duty;
57
if (size != 4) {
50
+ qemu_set_irq(p->module->duty_gpio_out[p->index], p->duty);
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)
51
}
294
}
52
}
295
}
53
296
54
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_init(Object *obj)
297
-static uint64_t omap_uwire_read(void *opaque, hwaddr addr,
55
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
298
- unsigned size)
299
+static uint64_t omap_uwire_read(void *opaque, hwaddr addr, unsigned size)
300
{
301
- struct omap_uwire_s *s = (struct omap_uwire_s *) opaque;
302
+ struct omap_uwire_s *s = opaque;
303
int offset = addr & OMAP_MPUI_REG_MASK;
304
305
if (size != 2) {
306
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_uwire_read(void *opaque, hwaddr addr,
307
static void omap_uwire_write(void *opaque, hwaddr addr,
308
uint64_t value, unsigned size)
309
{
310
- struct omap_uwire_s *s = (struct omap_uwire_s *) opaque;
311
+ struct omap_uwire_s *s = opaque;
312
int offset = addr & OMAP_MPUI_REG_MASK;
313
314
if (size != 2) {
315
@@ -XXX,XX +XXX,XX @@ static void omap_pwl_update(struct omap_pwl_s *s)
316
}
317
}
318
319
-static uint64_t omap_pwl_read(void *opaque, hwaddr addr,
320
- unsigned size)
321
+static uint64_t omap_pwl_read(void *opaque, hwaddr addr, unsigned size)
322
{
323
- struct omap_pwl_s *s = (struct omap_pwl_s *) opaque;
324
+ struct omap_pwl_s *s = opaque;
325
int offset = addr & OMAP_MPUI_REG_MASK;
326
327
if (size != 1) {
328
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_pwl_read(void *opaque, hwaddr addr,
329
static void omap_pwl_write(void *opaque, hwaddr addr,
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;
348
};
349
350
-static uint64_t omap_pwt_read(void *opaque, hwaddr addr,
351
- unsigned size)
352
+static uint64_t omap_pwt_read(void *opaque, hwaddr addr, unsigned size)
353
{
354
- struct omap_pwt_s *s = (struct omap_pwt_s *) opaque;
355
+ struct omap_pwt_s *s = opaque;
356
int offset = addr & OMAP_MPUI_REG_MASK;
357
358
if (size != 1) {
359
@@ -XXX,XX +XXX,XX @@ static uint64_t omap_pwt_read(void *opaque, hwaddr addr,
360
static void omap_pwt_write(void *opaque, hwaddr addr,
361
uint64_t value, unsigned size)
362
{
363
- struct omap_pwt_s *s = (struct omap_pwt_s *) opaque;
364
+ struct omap_pwt_s *s = opaque;
365
int offset = addr & OMAP_MPUI_REG_MASK;
366
367
if (size != 1) {
368
@@ -XXX,XX +XXX,XX @@ static void omap_rtc_alarm_update(struct omap_rtc_s *s)
369
printf("%s: conversion failed\n", __func__);
370
}
371
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,
633
}
634
}
635
636
-static void omap_sysctl_write(void *opaque, hwaddr addr,
637
- uint32_t value)
638
+static void omap_sysctl_write(void *opaque, hwaddr addr, uint32_t value)
639
{
640
- struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque;
641
+ struct omap_sysctl_s *s = opaque;
642
643
switch (addr) {
644
case 0x000:    /* CONTROL_REVISION */
645
@@ -XXX,XX +XXX,XX @@ static struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
646
/* General chip reset */
647
static void omap2_mpu_reset(void *opaque)
648
{
649
- struct omap_mpu_state_s *mpu = (struct omap_mpu_state_s *) opaque;
650
+ struct omap_mpu_state_s *mpu = opaque;
651
652
omap_dma_reset(mpu->dma);
653
omap_prcm_reset(mpu->prcm);
654
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
655
index XXXXXXX..XXXXXXX 100644
656
--- a/hw/arm/omap_sx1.c
657
+++ b/hw/arm/omap_sx1.c
658
@@ -XXX,XX +XXX,XX @@
659
static uint64_t static_read(void *opaque, hwaddr offset,
660
unsigned size)
661
{
662
- uint32_t *val = (uint32_t *) opaque;
663
+ uint32_t *val = opaque;
664
uint32_t mask = (4 / size) - 1;
665
666
return *val >> ((offset & mask) << 3);
667
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
668
index XXXXXXX..XXXXXXX 100644
669
--- a/hw/arm/palm.c
670
+++ b/hw/arm/palm.c
671
@@ -XXX,XX +XXX,XX @@ static struct {
672
673
static void palmte_button_event(void *opaque, int keycode)
674
{
675
- struct omap_mpu_state_s *cpu = (struct omap_mpu_state_s *) opaque;
676
+ struct omap_mpu_state_s *cpu = opaque;
677
678
if (palmte_keymap[keycode & 0x7f].row != -1)
679
omap_mpuio_key(cpu->mpuio,
680
diff --git a/hw/char/omap_uart.c b/hw/char/omap_uart.c
681
index XXXXXXX..XXXXXXX 100644
682
--- a/hw/char/omap_uart.c
683
+++ b/hw/char/omap_uart.c
684
@@ -XXX,XX +XXX,XX @@ struct omap_uart_s *omap_uart_init(hwaddr base,
685
return s;
686
}
687
688
-static uint64_t omap_uart_read(void *opaque, hwaddr addr,
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;
56
int i;
844
int i;
57
845
58
+ QEMU_BUILD_BUG_ON(ARRAY_SIZE(s->pwm) != NPCM7XX_PWM_PER_MODULE);
846
s->dma->freq = omap_clk_getrate(s->clk);
59
for (i = 0; i < NPCM7XX_PWM_PER_MODULE; i++) {
847
@@ -XXX,XX +XXX,XX @@ static void omap_dma_interrupts_4_update(struct omap_dma_s *s)
60
NPCM7xxPWM *p = &s->pwm[i];
848
static uint64_t omap_dma4_read(void *opaque, hwaddr addr,
61
p->module = s;
849
unsigned size)
62
@@ -XXX,XX +XXX,XX @@ static void npcm7xx_pwm_init(Object *obj)
850
{
63
object_property_add_uint32_ptr(obj, "duty[*]",
851
- struct omap_dma_s *s = (struct omap_dma_s *) opaque;
64
&s->pwm[i].duty, OBJ_PROP_FLAG_READ);
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)
65
}
1233
}
66
+ qdev_init_gpio_out_named(DEVICE(s), s->duty_gpio_out,
1234
}
67
+ "duty-gpio-out", NPCM7XX_PWM_PER_MODULE);
1235
68
}
1236
-static void omap_gp_timer_write(void *opaque, hwaddr addr,
69
1237
- uint32_t value)
70
static const VMStateDescription vmstate_npcm7xx_pwm = {
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)
71
--
1280
--
72
2.20.1
1281
2.34.1
73
1282
74
1283
diff view generated by jsdifflib
1
For a long time now the UI layer has guaranteed that the console
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
surface is always 32 bits per pixel. Remove the legacy dead code
3
from the pxa2xx_lcd display device which was handling the possibility
4
that the console surface was some other format.
5
2
3
Following docs/devel/style.rst guidelines, rename omap_gpif_s ->
4
Omap1GpioState. This also remove a use of 'struct' in the
5
DECLARE_INSTANCE_CHECKER() macro call.
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-5-philmd@linaro.org
6
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
8
Message-id: 20210211141515.8755-5-peter.maydell@linaro.org
9
---
11
---
10
hw/display/pxa2xx_lcd.c | 79 +++++++++--------------------------------
12
include/hw/arm/omap.h | 6 +++---
11
1 file changed, 17 insertions(+), 62 deletions(-)
13
hw/gpio/omap_gpio.c | 16 ++++++++--------
14
2 files changed, 11 insertions(+), 11 deletions(-)
12
15
13
diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c
16
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
14
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/display/pxa2xx_lcd.c
18
--- a/include/hw/arm/omap.h
16
+++ b/hw/display/pxa2xx_lcd.c
19
+++ b/include/hw/arm/omap.h
17
@@ -XXX,XX +XXX,XX @@ struct PXA2xxLCDState {
20
@@ -XXX,XX +XXX,XX @@ void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk);
18
21
19
int invalidated;
22
/* omap_gpio.c */
20
QemuConsole *con;
23
#define TYPE_OMAP1_GPIO "omap-gpio"
21
- drawfn *line_fn[2];
24
-DECLARE_INSTANCE_CHECKER(struct omap_gpif_s, OMAP1_GPIO,
22
int dest_width;
25
+typedef struct Omap1GpioState Omap1GpioState;
23
int xres, yres;
26
+DECLARE_INSTANCE_CHECKER(Omap1GpioState, OMAP1_GPIO,
24
int pal_for;
27
TYPE_OMAP1_GPIO)
25
@@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED {
28
26
#define LDCMD_SOFINT    (1 << 22)
29
#define TYPE_OMAP2_GPIO "omap2-gpio"
27
#define LDCMD_PAL    (1 << 26)
30
DECLARE_INSTANCE_CHECKER(struct omap2_gpif_s, OMAP2_GPIO,
28
31
TYPE_OMAP2_GPIO)
29
+#define BITS 32
32
30
+#include "pxa2xx_template.h"
33
-typedef struct omap_gpif_s omap_gpif;
31
+
34
typedef struct omap2_gpif_s omap2_gpif;
32
/* Route internal interrupt lines to the global IC */
35
33
static void pxa2xx_lcdc_int_update(PXA2xxLCDState *s)
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;
48
};
49
50
-struct omap_gpif_s {
51
+struct Omap1GpioState {
52
SysBusDevice parent_obj;
53
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)
34
{
58
{
35
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_palette_parse(PXA2xxLCDState *s, int ch, int bpp)
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)
36
}
92
}
37
}
93
}
38
94
39
+static inline drawfn pxa2xx_drawfn(PXA2xxLCDState *s)
95
-void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk)
40
+{
96
+void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk)
41
+ if (s->transp) {
42
+ return pxa2xx_draw_fn_32t[s->bpp];
43
+ } else {
44
+ return pxa2xx_draw_fn_32[s->bpp];
45
+ }
46
+}
47
+
48
static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s,
49
hwaddr addr, int *miny, int *maxy)
50
{
97
{
51
DisplaySurface *surface = qemu_console_surface(s->con);
98
gpio->clk = clk;
52
int src_width, dest_width;
99
}
53
- drawfn fn = NULL;
100
54
- if (s->dest_width)
101
static Property omap_gpio_properties[] = {
55
- fn = s->line_fn[s->transp][s->bpp];
102
- DEFINE_PROP_INT32("mpu_model", struct omap_gpif_s, mpu_model, 0),
56
+ drawfn fn = pxa2xx_drawfn(s);
103
+ DEFINE_PROP_INT32("mpu_model", Omap1GpioState, mpu_model, 0),
57
if (!fn)
104
DEFINE_PROP_END_OF_LIST(),
58
return;
59
60
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s,
61
{
62
DisplaySurface *surface = qemu_console_surface(s->con);
63
int src_width, dest_width;
64
- drawfn fn = NULL;
65
- if (s->dest_width)
66
- fn = s->line_fn[s->transp][s->bpp];
67
+ drawfn fn = pxa2xx_drawfn(s);
68
if (!fn)
69
return;
70
71
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
72
{
73
DisplaySurface *surface = qemu_console_surface(s->con);
74
int src_width, dest_width;
75
- drawfn fn = NULL;
76
- if (s->dest_width) {
77
- fn = s->line_fn[s->transp][s->bpp];
78
- }
79
+ drawfn fn = pxa2xx_drawfn(s);
80
if (!fn) {
81
return;
82
}
83
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s,
84
{
85
DisplaySurface *surface = qemu_console_surface(s->con);
86
int src_width, dest_width;
87
- drawfn fn = NULL;
88
- if (s->dest_width) {
89
- fn = s->line_fn[s->transp][s->bpp];
90
- }
91
+ drawfn fn = pxa2xx_drawfn(s);
92
if (!fn) {
93
return;
94
}
95
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_pxa2xx_lcdc = {
96
}
97
};
105
};
98
106
99
-#define BITS 8
107
@@ -XXX,XX +XXX,XX @@ static void omap_gpio_class_init(ObjectClass *klass, void *data)
100
-#include "pxa2xx_template.h"
108
static const TypeInfo omap_gpio_info = {
101
-#define BITS 15
109
.name = TYPE_OMAP1_GPIO,
102
-#include "pxa2xx_template.h"
110
.parent = TYPE_SYS_BUS_DEVICE,
103
-#define BITS 16
111
- .instance_size = sizeof(struct omap_gpif_s),
104
-#include "pxa2xx_template.h"
112
+ .instance_size = sizeof(Omap1GpioState),
105
-#define BITS 24
113
.instance_init = omap_gpio_init,
106
-#include "pxa2xx_template.h"
114
.class_init = omap_gpio_class_init,
107
-#define BITS 32
115
};
108
-#include "pxa2xx_template.h"
109
-
110
static const GraphicHwOps pxa2xx_ops = {
111
.invalidate = pxa2xx_invalidate_display,
112
.gfx_update = pxa2xx_update_display,
113
@@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
114
hwaddr base, qemu_irq irq)
115
{
116
PXA2xxLCDState *s;
117
- DisplaySurface *surface;
118
119
s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState));
120
s->invalidated = 1;
121
@@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
122
memory_region_add_subregion(sysmem, base, &s->iomem);
123
124
s->con = graphic_console_init(NULL, 0, &pxa2xx_ops, s);
125
- surface = qemu_console_surface(s->con);
126
-
127
- switch (surface_bits_per_pixel(surface)) {
128
- case 0:
129
- s->dest_width = 0;
130
- break;
131
- case 8:
132
- s->line_fn[0] = pxa2xx_draw_fn_8;
133
- s->line_fn[1] = pxa2xx_draw_fn_8t;
134
- s->dest_width = 1;
135
- break;
136
- case 15:
137
- s->line_fn[0] = pxa2xx_draw_fn_15;
138
- s->line_fn[1] = pxa2xx_draw_fn_15t;
139
- s->dest_width = 2;
140
- break;
141
- case 16:
142
- s->line_fn[0] = pxa2xx_draw_fn_16;
143
- s->line_fn[1] = pxa2xx_draw_fn_16t;
144
- s->dest_width = 2;
145
- break;
146
- case 24:
147
- s->line_fn[0] = pxa2xx_draw_fn_24;
148
- s->line_fn[1] = pxa2xx_draw_fn_24t;
149
- s->dest_width = 3;
150
- break;
151
- case 32:
152
- s->line_fn[0] = pxa2xx_draw_fn_32;
153
- s->line_fn[1] = pxa2xx_draw_fn_32t;
154
- s->dest_width = 4;
155
- break;
156
- default:
157
- fprintf(stderr, "%s: Bad color depth\n", __func__);
158
- exit(1);
159
- }
160
+ s->dest_width = 4;
161
162
vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s);
163
164
--
116
--
165
2.20.1
117
2.34.1
166
118
167
119
diff view generated by jsdifflib
1
Now that BITS is always 32, expand out all its uses in the template
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
header, including removing now-useless uses of the glue() macro.
3
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.
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-6-philmd@linaro.org
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
6
Message-id: 20210211141515.8755-7-peter.maydell@linaro.org
7
---
11
---
8
hw/display/pxa2xx_template.h | 110 ++++++++++++++---------------------
12
include/hw/arm/omap.h | 9 ++++-----
9
1 file changed, 45 insertions(+), 65 deletions(-)
13
hw/gpio/omap_gpio.c | 20 ++++++++++----------
14
2 files changed, 14 insertions(+), 15 deletions(-)
10
15
11
diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h
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/display/pxa2xx_template.h
18
--- a/include/hw/arm/omap.h
14
+++ b/hw/display/pxa2xx_template.h
19
+++ b/include/hw/arm/omap.h
15
@@ -XXX,XX +XXX,XX @@
20
@@ -XXX,XX +XXX,XX @@ DECLARE_INSTANCE_CHECKER(Omap1GpioState, OMAP1_GPIO,
16
*/
21
TYPE_OMAP1_GPIO)
17
22
18
# define SKIP_PIXEL(to)        to += deststep
23
#define TYPE_OMAP2_GPIO "omap2-gpio"
19
-#if BITS == 8
24
-DECLARE_INSTANCE_CHECKER(struct omap2_gpif_s, OMAP2_GPIO,
20
-# define COPY_PIXEL(to, from) do { *to = from; SKIP_PIXEL(to); } while (0)
25
+typedef struct Omap2GpioState Omap2GpioState;
21
-#elif BITS == 15 || BITS == 16
26
+DECLARE_INSTANCE_CHECKER(Omap2GpioState, OMAP2_GPIO,
22
-# define COPY_PIXEL(to, from) \
27
TYPE_OMAP2_GPIO)
23
- do { \
28
24
- *(uint16_t *) to = from; \
29
-typedef struct omap2_gpif_s omap2_gpif;
25
- SKIP_PIXEL(to); \
30
-
26
- } while (0)
31
/* TODO: clock framework (see above) */
27
-#elif BITS == 24
32
void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk);
28
-# define COPY_PIXEL(to, from) \
33
29
- do { \
34
-void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk);
30
- *(uint16_t *) to = from; \
35
-void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk);
31
- *(to + 2) = (from) >> 16; \
36
+void omap2_gpio_set_iclk(Omap2GpioState *gpio, omap_clk clk);
32
- SKIP_PIXEL(to); \
37
+void omap2_gpio_set_fclk(Omap2GpioState *gpio, uint8_t i, omap_clk clk);
33
- } while (0)
38
34
-#elif BITS == 32
39
/* OMAP2 l4 Interconnect */
35
# define COPY_PIXEL(to, from) \
40
struct omap_l4_s;
36
do { \
41
diff --git a/hw/gpio/omap_gpio.c b/hw/gpio/omap_gpio.c
37
*(uint32_t *) to = from; \
42
index XXXXXXX..XXXXXXX 100644
38
SKIP_PIXEL(to); \
43
--- a/hw/gpio/omap_gpio.c
39
} while (0)
44
+++ b/hw/gpio/omap_gpio.c
40
-#else
45
@@ -XXX,XX +XXX,XX @@ struct omap2_gpio_s {
41
-# error unknown bit depth
46
uint8_t delay;
42
-#endif
47
};
43
48
44
#ifdef HOST_WORDS_BIGENDIAN
49
-struct omap2_gpif_s {
45
# define SWAP_WORDS    1
50
+struct Omap2GpioState {
46
@@ -XXX,XX +XXX,XX @@
51
SysBusDevice parent_obj;
47
#define FN_2(x)        FN(x + 1) FN(x)
52
48
#define FN_4(x)        FN_2(x + 2) FN_2(x)
53
MemoryRegion iomem;
49
54
@@ -XXX,XX +XXX,XX @@ static inline void omap2_gpio_module_int(struct omap2_gpio_s *s, int line)
50
-static void glue(pxa2xx_draw_line2_, BITS)(void *opaque,
55
51
+static void pxa2xx_draw_line2(void *opaque,
56
static void omap2_gpio_set(void *opaque, int line, int level)
52
uint8_t *dest, const uint8_t *src, int width, int deststep)
53
{
57
{
54
uint32_t *palette = opaque;
58
- struct omap2_gpif_s *p = opaque;
55
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line2_, BITS)(void *opaque,
59
+ Omap2GpioState *p = opaque;
56
}
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;
57
}
107
}
58
108
59
-static void glue(pxa2xx_draw_line4_, BITS)(void *opaque,
109
-void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk)
60
+static void pxa2xx_draw_line4(void *opaque,
110
+void omap2_gpio_set_fclk(Omap2GpioState *gpio, uint8_t i, omap_clk clk)
61
uint8_t *dest, const uint8_t *src, int width, int deststep)
62
{
111
{
63
uint32_t *palette = opaque;
112
assert(i <= 5);
64
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line4_, BITS)(void *opaque,
113
gpio->fclk[i] = clk;
65
}
66
}
114
}
67
115
68
-static void glue(pxa2xx_draw_line8_, BITS)(void *opaque,
116
static Property omap2_gpio_properties[] = {
69
+static void pxa2xx_draw_line8(void *opaque,
117
- DEFINE_PROP_INT32("mpu_model", struct omap2_gpif_s, mpu_model, 0),
70
uint8_t *dest, const uint8_t *src, int width, int deststep)
118
+ DEFINE_PROP_INT32("mpu_model", Omap2GpioState, mpu_model, 0),
71
{
119
DEFINE_PROP_END_OF_LIST(),
72
uint32_t *palette = opaque;
73
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line8_, BITS)(void *opaque,
74
}
75
}
76
77
-static void glue(pxa2xx_draw_line16_, BITS)(void *opaque,
78
+static void pxa2xx_draw_line16(void *opaque,
79
uint8_t *dest, const uint8_t *src, int width, int deststep)
80
{
81
uint32_t data;
82
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16_, BITS)(void *opaque,
83
data >>= 6;
84
r = (data & 0x1f) << 3;
85
data >>= 5;
86
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
87
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
88
b = (data & 0x1f) << 3;
89
data >>= 5;
90
g = (data & 0x3f) << 2;
91
data >>= 6;
92
r = (data & 0x1f) << 3;
93
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
94
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
95
width -= 2;
96
src += 4;
97
}
98
}
99
100
-static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque,
101
+static void pxa2xx_draw_line16t(void *opaque,
102
uint8_t *dest, const uint8_t *src, int width, int deststep)
103
{
104
uint32_t data;
105
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque,
106
if (data & 1)
107
SKIP_PIXEL(dest);
108
else
109
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
110
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
111
data >>= 1;
112
b = (data & 0x1f) << 3;
113
data >>= 5;
114
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line16t_, BITS)(void *opaque,
115
if (data & 1)
116
SKIP_PIXEL(dest);
117
else
118
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
119
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
120
width -= 2;
121
src += 4;
122
}
123
}
124
125
-static void glue(pxa2xx_draw_line18_, BITS)(void *opaque,
126
+static void pxa2xx_draw_line18(void *opaque,
127
uint8_t *dest, const uint8_t *src, int width, int deststep)
128
{
129
uint32_t data;
130
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line18_, BITS)(void *opaque,
131
g = (data & 0x3f) << 2;
132
data >>= 6;
133
r = (data & 0x3f) << 2;
134
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
135
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
136
width -= 1;
137
src += 4;
138
}
139
}
140
141
/* The wicked packed format */
142
-static void glue(pxa2xx_draw_line18p_, BITS)(void *opaque,
143
+static void pxa2xx_draw_line18p(void *opaque,
144
uint8_t *dest, const uint8_t *src, int width, int deststep)
145
{
146
uint32_t data[3];
147
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line18p_, BITS)(void *opaque,
148
data[0] >>= 6;
149
r = (data[0] & 0x3f) << 2;
150
data[0] >>= 12;
151
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
152
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
153
b = (data[0] & 0x3f) << 2;
154
data[0] >>= 6;
155
g = ((data[1] & 0xf) << 4) | (data[0] << 2);
156
data[1] >>= 4;
157
r = (data[1] & 0x3f) << 2;
158
data[1] >>= 12;
159
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
160
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
161
b = (data[1] & 0x3f) << 2;
162
data[1] >>= 6;
163
g = (data[1] & 0x3f) << 2;
164
data[1] >>= 6;
165
r = ((data[2] & 0x3) << 6) | (data[1] << 2);
166
data[2] >>= 8;
167
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
168
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
169
b = (data[2] & 0x3f) << 2;
170
data[2] >>= 6;
171
g = (data[2] & 0x3f) << 2;
172
data[2] >>= 6;
173
r = data[2] << 2;
174
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
175
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
176
width -= 4;
177
}
178
}
179
180
-static void glue(pxa2xx_draw_line19_, BITS)(void *opaque,
181
+static void pxa2xx_draw_line19(void *opaque,
182
uint8_t *dest, const uint8_t *src, int width, int deststep)
183
{
184
uint32_t data;
185
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19_, BITS)(void *opaque,
186
if (data & 1)
187
SKIP_PIXEL(dest);
188
else
189
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
190
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
191
width -= 1;
192
src += 4;
193
}
194
}
195
196
/* The wicked packed format */
197
-static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque,
198
+static void pxa2xx_draw_line19p(void *opaque,
199
uint8_t *dest, const uint8_t *src, int width, int deststep)
200
{
201
uint32_t data[3];
202
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque,
203
if (data[0] & 1)
204
SKIP_PIXEL(dest);
205
else
206
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
207
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
208
data[0] >>= 6;
209
b = (data[0] & 0x3f) << 2;
210
data[0] >>= 6;
211
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque,
212
if (data[1] & 1)
213
SKIP_PIXEL(dest);
214
else
215
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
216
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
217
data[1] >>= 6;
218
b = (data[1] & 0x3f) << 2;
219
data[1] >>= 6;
220
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque,
221
if (data[2] & 1)
222
SKIP_PIXEL(dest);
223
else
224
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
225
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
226
data[2] >>= 6;
227
b = (data[2] & 0x3f) << 2;
228
data[2] >>= 6;
229
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line19p_, BITS)(void *opaque,
230
if (data[2] & 1)
231
SKIP_PIXEL(dest);
232
else
233
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
234
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
235
width -= 4;
236
}
237
}
238
239
-static void glue(pxa2xx_draw_line24_, BITS)(void *opaque,
240
+static void pxa2xx_draw_line24(void *opaque,
241
uint8_t *dest, const uint8_t *src, int width, int deststep)
242
{
243
uint32_t data;
244
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line24_, BITS)(void *opaque,
245
g = data & 0xff;
246
data >>= 8;
247
r = data & 0xff;
248
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
249
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
250
width -= 1;
251
src += 4;
252
}
253
}
254
255
-static void glue(pxa2xx_draw_line24t_, BITS)(void *opaque,
256
+static void pxa2xx_draw_line24t(void *opaque,
257
uint8_t *dest, const uint8_t *src, int width, int deststep)
258
{
259
uint32_t data;
260
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line24t_, BITS)(void *opaque,
261
if (data & 1)
262
SKIP_PIXEL(dest);
263
else
264
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
265
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
266
width -= 1;
267
src += 4;
268
}
269
}
270
271
-static void glue(pxa2xx_draw_line25_, BITS)(void *opaque,
272
+static void pxa2xx_draw_line25(void *opaque,
273
uint8_t *dest, const uint8_t *src, int width, int deststep)
274
{
275
uint32_t data;
276
@@ -XXX,XX +XXX,XX @@ static void glue(pxa2xx_draw_line25_, BITS)(void *opaque,
277
if (data & 1)
278
SKIP_PIXEL(dest);
279
else
280
- COPY_PIXEL(dest, glue(rgb_to_pixel, BITS)(r, g, b));
281
+ COPY_PIXEL(dest, rgb_to_pixel32(r, g, b));
282
width -= 1;
283
src += 4;
284
}
285
}
286
287
/* Overlay planes disabled, no transparency */
288
-static drawfn glue(pxa2xx_draw_fn_, BITS)[16] =
289
+static drawfn pxa2xx_draw_fn_32[16] =
290
{
291
[0 ... 0xf] = NULL,
292
- [pxa_lcdc_2bpp] = glue(pxa2xx_draw_line2_, BITS),
293
- [pxa_lcdc_4bpp] = glue(pxa2xx_draw_line4_, BITS),
294
- [pxa_lcdc_8bpp] = glue(pxa2xx_draw_line8_, BITS),
295
- [pxa_lcdc_16bpp] = glue(pxa2xx_draw_line16_, BITS),
296
- [pxa_lcdc_18bpp] = glue(pxa2xx_draw_line18_, BITS),
297
- [pxa_lcdc_18pbpp] = glue(pxa2xx_draw_line18p_, BITS),
298
- [pxa_lcdc_24bpp] = glue(pxa2xx_draw_line24_, BITS),
299
+ [pxa_lcdc_2bpp] = pxa2xx_draw_line2,
300
+ [pxa_lcdc_4bpp] = pxa2xx_draw_line4,
301
+ [pxa_lcdc_8bpp] = pxa2xx_draw_line8,
302
+ [pxa_lcdc_16bpp] = pxa2xx_draw_line16,
303
+ [pxa_lcdc_18bpp] = pxa2xx_draw_line18,
304
+ [pxa_lcdc_18pbpp] = pxa2xx_draw_line18p,
305
+ [pxa_lcdc_24bpp] = pxa2xx_draw_line24,
306
};
120
};
307
121
308
/* Overlay planes enabled, transparency used */
122
@@ -XXX,XX +XXX,XX @@ static void omap2_gpio_class_init(ObjectClass *klass, void *data)
309
-static drawfn glue(glue(pxa2xx_draw_fn_, BITS), t)[16] =
123
static const TypeInfo omap2_gpio_info = {
310
+static drawfn pxa2xx_draw_fn_32t[16] =
124
.name = TYPE_OMAP2_GPIO,
311
{
125
.parent = TYPE_SYS_BUS_DEVICE,
312
[0 ... 0xf] = NULL,
126
- .instance_size = sizeof(struct omap2_gpif_s),
313
- [pxa_lcdc_4bpp] = glue(pxa2xx_draw_line4_, BITS),
127
+ .instance_size = sizeof(Omap2GpioState),
314
- [pxa_lcdc_8bpp] = glue(pxa2xx_draw_line8_, BITS),
128
.class_init = omap2_gpio_class_init,
315
- [pxa_lcdc_16bpp] = glue(pxa2xx_draw_line16t_, BITS),
316
- [pxa_lcdc_19bpp] = glue(pxa2xx_draw_line19_, BITS),
317
- [pxa_lcdc_19pbpp] = glue(pxa2xx_draw_line19p_, BITS),
318
- [pxa_lcdc_24bpp] = glue(pxa2xx_draw_line24t_, BITS),
319
- [pxa_lcdc_25bpp] = glue(pxa2xx_draw_line25_, BITS),
320
+ [pxa_lcdc_4bpp] = pxa2xx_draw_line4,
321
+ [pxa_lcdc_8bpp] = pxa2xx_draw_line8,
322
+ [pxa_lcdc_16bpp] = pxa2xx_draw_line16t,
323
+ [pxa_lcdc_19bpp] = pxa2xx_draw_line19,
324
+ [pxa_lcdc_19pbpp] = pxa2xx_draw_line19p,
325
+ [pxa_lcdc_24bpp] = pxa2xx_draw_line24t,
326
+ [pxa_lcdc_25bpp] = pxa2xx_draw_line25,
327
};
129
};
328
130
329
-#undef BITS
330
#undef COPY_PIXEL
331
#undef SKIP_PIXEL
332
333
--
131
--
334
2.20.1
132
2.34.1
335
133
336
134
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
If the whole SID range (32b) is invalidated (SMMU_CMD_CFGI_ALL),
3
Following docs/devel/style.rst guidelines, rename
4
@end overflows and we fail to handle the command properly.
4
omap_intr_handler_s -> OMAPIntcState. This also remove a
5
5
use of 'struct' in the DECLARE_INSTANCE_CHECKER() macro call.
6
Once this gets fixed, the current code really is awkward in the
6
7
sense it loops over the whole range instead of removing the
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
currently cached configs through a hash table lookup.
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
9
Message-id: 20230109140306.23161-7-philmd@linaro.org
10
Fix both the overflow and the lookup.
11
12
Signed-off-by: Eric Auger <eric.auger@redhat.com>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Message-id: 20210309102742.30442-7-eric.auger@redhat.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
11
---
17
hw/arm/smmu-internal.h | 5 +++++
12
include/hw/arm/omap.h | 9 ++++-----
18
hw/arm/smmuv3.c | 34 ++++++++++++++++++++--------------
13
hw/intc/omap_intc.c | 38 +++++++++++++++++++-------------------
19
2 files changed, 25 insertions(+), 14 deletions(-)
14
2 files changed, 23 insertions(+), 24 deletions(-)
20
15
21
diff --git a/hw/arm/smmu-internal.h b/hw/arm/smmu-internal.h
16
diff --git a/include/hw/arm/omap.h b/include/hw/arm/omap.h
22
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
23
--- a/hw/arm/smmu-internal.h
18
--- a/include/hw/arm/omap.h
24
+++ b/hw/arm/smmu-internal.h
19
+++ b/include/hw/arm/omap.h
25
@@ -XXX,XX +XXX,XX @@ typedef struct SMMUIOTLBPageInvInfo {
20
@@ -XXX,XX +XXX,XX @@ void omap_clk_reparent(omap_clk clk, omap_clk parent);
26
uint64_t mask;
21
27
} SMMUIOTLBPageInvInfo;
22
/* omap_intc.c */
28
23
#define TYPE_OMAP_INTC "common-omap-intc"
29
+typedef struct SMMUSIDRange {
24
-typedef struct omap_intr_handler_s omap_intr_handler;
30
+ uint32_t start;
25
-DECLARE_INSTANCE_CHECKER(omap_intr_handler, OMAP_INTC,
31
+ uint32_t end;
26
- TYPE_OMAP_INTC)
32
+} SMMUSIDRange;
27
+typedef struct OMAPIntcState OMAPIntcState;
33
+
28
+DECLARE_INSTANCE_CHECKER(OMAPIntcState, OMAP_INTC, TYPE_OMAP_INTC)
34
#endif
29
35
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
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
36
index XXXXXXX..XXXXXXX 100644
44
index XXXXXXX..XXXXXXX 100644
37
--- a/hw/arm/smmuv3.c
45
--- a/hw/intc/omap_intc.c
38
+++ b/hw/arm/smmuv3.c
46
+++ b/hw/intc/omap_intc.c
39
@@ -XXX,XX +XXX,XX @@
47
@@ -XXX,XX +XXX,XX @@ struct omap_intr_handler_bank_s {
40
48
unsigned char priority[32];
41
#include "hw/arm/smmuv3.h"
49
};
42
#include "smmuv3-internal.h"
50
43
+#include "smmu-internal.h"
51
-struct omap_intr_handler_s {
44
52
+struct OMAPIntcState {
45
/**
53
SysBusDevice parent_obj;
46
* smmuv3_trigger_irq - pulse @irq if enabled and update
54
47
@@ -XXX,XX +XXX,XX @@ static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
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");
48
}
137
}
49
}
138
}
50
139
51
+static gboolean
140
-void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk)
52
+smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)
141
+void omap_intc_set_iclk(OMAPIntcState *intc, omap_clk clk)
53
+{
142
{
54
+ SMMUDevice *sdev = (SMMUDevice *)key;
143
intc->iclk = clk;
55
+ uint32_t sid = smmu_get_sid(sdev);
144
}
56
+ SMMUSIDRange *sid_range = (SMMUSIDRange *)user_data;
145
57
+
146
-void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk)
58
+ if (sid < sid_range->start || sid > sid_range->end) {
147
+void omap_intc_set_fclk(OMAPIntcState *intc, omap_clk clk)
59
+ return false;
148
{
60
+ }
149
intc->fclk = clk;
61
+ trace_smmuv3_config_cache_inv(sid);
150
}
62
+ return true;
151
63
+}
152
static Property omap_intc_properties[] = {
64
+
153
- DEFINE_PROP_UINT32("size", struct omap_intr_handler_s, size, 0x100),
65
static int smmuv3_cmdq_consume(SMMUv3State *s)
154
+ DEFINE_PROP_UINT32("size", OMAPIntcState, size, 0x100),
66
{
155
DEFINE_PROP_END_OF_LIST(),
67
SMMUState *bs = ARM_SMMU(s);
156
};
68
@@ -XXX,XX +XXX,XX @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
157
69
}
158
@@ -XXX,XX +XXX,XX @@ static const TypeInfo omap_intc_info = {
70
case SMMU_CMD_CFGI_STE_RANGE: /* same as SMMU_CMD_CFGI_ALL */
159
static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
71
{
160
unsigned size)
72
- uint32_t start = CMD_SID(&cmd), end, i;
161
{
73
+ uint32_t start = CMD_SID(&cmd);
162
- struct omap_intr_handler_s *s = opaque;
74
uint8_t range = CMD_STE_RANGE(&cmd);
163
+ OMAPIntcState *s = opaque;
75
+ uint64_t end = start + (1ULL << (range + 1)) - 1;
164
int offset = addr;
76
+ SMMUSIDRange sid_range = {start, end};
165
int bank_no, line_no;
77
166
struct omap_intr_handler_bank_s *bank = NULL;
78
if (CMD_SSEC(&cmd)) {
167
@@ -XXX,XX +XXX,XX @@ static uint64_t omap2_inth_read(void *opaque, hwaddr addr,
79
cmd_error = SMMU_CERROR_ILL;
168
static void omap2_inth_write(void *opaque, hwaddr addr,
80
break;
169
uint64_t value, unsigned size)
81
}
170
{
82
-
171
- struct omap_intr_handler_s *s = opaque;
83
- end = start + (1 << (range + 1)) - 1;
172
+ OMAPIntcState *s = opaque;
84
trace_smmuv3_cmdq_cfgi_ste_range(start, end);
173
int offset = addr;
85
-
174
int bank_no, line_no;
86
- for (i = start; i <= end; i++) {
175
struct omap_intr_handler_bank_s *bank = NULL;
87
- IOMMUMemoryRegion *mr = smmu_iommu_mr(bs, i);
176
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps omap2_inth_mem_ops = {
88
- SMMUDevice *sdev;
177
static void omap2_intc_init(Object *obj)
89
-
178
{
90
- if (!mr) {
179
DeviceState *dev = DEVICE(obj);
91
- continue;
180
- struct omap_intr_handler_s *s = OMAP_INTC(obj);
92
- }
181
+ OMAPIntcState *s = OMAP_INTC(obj);
93
- sdev = container_of(mr, SMMUDevice, iommu);
182
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
94
- smmuv3_flush_config(sdev);
183
95
- }
184
s->level_only = 1;
96
+ g_hash_table_foreach_remove(bs->configs, smmuv3_invalidate_ste,
185
@@ -XXX,XX +XXX,XX @@ static void omap2_intc_init(Object *obj)
97
+ &sid_range);
186
98
break;
187
static void omap2_intc_realize(DeviceState *dev, Error **errp)
99
}
188
{
100
case SMMU_CMD_CFGI_CD:
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
};
211
101
--
212
--
102
2.20.1
213
2.34.1
103
214
104
215
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Wrote too much with punpk1 with vl % 512 != 0.
3
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
4
4
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
5
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
5
Message-id: 20230109140306.23161-8-philmd@linaro.org
6
Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
7
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
8
Message-id: 20210309155305.11301-4-richard.henderson@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
target/arm/sve_helper.c | 4 ++--
8
hw/arm/stellaris.c | 6 +++---
12
1 file changed, 2 insertions(+), 2 deletions(-)
9
1 file changed, 3 insertions(+), 3 deletions(-)
13
10
14
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
11
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
15
index XXXXXXX..XXXXXXX 100644
12
index XXXXXXX..XXXXXXX 100644
16
--- a/target/arm/sve_helper.c
13
--- a/hw/arm/stellaris.c
17
+++ b/target/arm/sve_helper.c
14
+++ b/hw/arm/stellaris.c
18
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_punpk_p)(void *vd, void *vn, uint32_t pred_desc)
15
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_update(stellaris_adc_state *s)
19
high = oprsz >> 1;
16
20
}
17
static void stellaris_adc_trigger(void *opaque, int irq, int level)
21
18
{
22
- if ((high & 3) == 0) {
19
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
23
+ if ((oprsz & 7) == 0) {
20
+ stellaris_adc_state *s = opaque;
24
uint32_t *n = vn;
21
int n;
25
high >>= 2;
22
26
23
for (n = 0; n < 4; n++) {
27
- for (i = 0; i < DIV_ROUND_UP(oprsz, 8); i++) {
24
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_reset(stellaris_adc_state *s)
28
+ for (i = 0; i < oprsz / 8; i++) {
25
static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
29
uint64_t nn = n[H4(high + i)];
26
unsigned size)
30
d[i] = expand_bits(nn, 0);
27
{
31
}
28
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
29
+ stellaris_adc_state *s = opaque;
30
31
/* TODO: Implement this. */
32
if (offset >= 0x40 && offset < 0xc0) {
33
@@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
34
static void stellaris_adc_write(void *opaque, hwaddr offset,
35
uint64_t value, unsigned size)
36
{
37
- stellaris_adc_state *s = (stellaris_adc_state *)opaque;
38
+ stellaris_adc_state *s = opaque;
39
40
/* TODO: Implement this. */
41
if (offset >= 0x40 && offset < 0xc0) {
32
--
42
--
33
2.20.1
43
2.34.1
34
44
35
45
diff view generated by jsdifflib
1
From: Niek Linnenbank <nieklinnenbank@gmail.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Currently the emulated EMAC for sun8i always traverses the transmit queue
3
Following docs/devel/style.rst guidelines, rename
4
from the head when transferring packets. It searches for a list of consecutive
4
stellaris_adc_state -> StellarisADCState. This also remove a
5
descriptors whichs are flagged as ready for processing and transmits their payloads
5
use of 'struct' in the DECLARE_INSTANCE_CHECKER() macro call.
6
accordingly. The controller stops processing once it finds a descriptor that is not
7
marked ready.
8
6
9
While the above behaviour works in most situations, it is not the same as the actual
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
10
EMAC in hardware. Actual hardware uses the TX_CUR_DESC register value to keep track
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
11
of the last position in the transmit queue and continues processing from that position
9
Message-id: 20230109140306.23161-9-philmd@linaro.org
12
when software triggers the start of DMA processing. The currently emulated behaviour can
13
lead to packet loss on transmit when software fills the transmit queue with ready
14
descriptors that overlap the tail of the circular list.
15
16
This commit modifies the emulated EMAC for sun8i such that it processes
17
the transmit queue using the TX_CUR_DESC register in the same way as hardware.
18
19
Signed-off-by: Niek Linnenbank <nieklinnenbank@gmail.com>
20
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
21
Message-id: 20210310195820.21950-2-nieklinnenbank@gmail.com
22
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
23
---
11
---
24
hw/net/allwinner-sun8i-emac.c | 62 +++++++++++++++++++----------------
12
hw/arm/stellaris.c | 73 +++++++++++++++++++++++-----------------------
25
1 file changed, 34 insertions(+), 28 deletions(-)
13
1 file changed, 36 insertions(+), 37 deletions(-)
26
14
27
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
15
diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c
28
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
29
--- a/hw/net/allwinner-sun8i-emac.c
17
--- a/hw/arm/stellaris.c
30
+++ b/hw/net/allwinner-sun8i-emac.c
18
+++ b/hw/arm/stellaris.c
31
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_update_irq(AwSun8iEmacState *s)
19
@@ -XXX,XX +XXX,XX @@ static void stellaris_i2c_init(Object *obj)
32
qemu_set_irq(s->irq, (s->int_sta & s->int_en) != 0);
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];
33
}
42
}
34
43
35
-static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
44
-static void stellaris_adc_fifo_write(stellaris_adc_state *s, int n,
36
- FrameDescriptor *desc,
45
+static void stellaris_adc_fifo_write(StellarisADCState *s, int n,
37
- size_t min_size)
46
uint32_t value)
38
+static bool allwinner_sun8i_emac_desc_owned(FrameDescriptor *desc,
39
+ size_t min_buf_size)
40
{
47
{
41
- uint32_t paddr = desc->next;
48
int head;
42
-
49
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_fifo_write(stellaris_adc_state *s, int n,
43
- dma_memory_read(&s->dma_as, paddr, desc, sizeof(*desc));
50
s->fifo[n].state |= STELLARIS_ADC_FIFO_FULL;
44
-
45
- if ((desc->status & DESC_STATUS_CTL) &&
46
- (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
47
- return paddr;
48
- } else {
49
- return 0;
50
- }
51
+ return (desc->status & DESC_STATUS_CTL) && (min_buf_size == 0 ||
52
+ (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_buf_size);
53
}
51
}
54
52
55
-static uint32_t allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
53
-static void stellaris_adc_update(stellaris_adc_state *s)
56
- FrameDescriptor *desc,
54
+static void stellaris_adc_update(StellarisADCState *s)
57
- uint32_t start_addr,
58
- size_t min_size)
59
+static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
60
+ FrameDescriptor *desc,
61
+ uint32_t phys_addr)
62
+{
63
+ dma_memory_read(&s->dma_as, phys_addr, desc, sizeof(*desc));
64
+}
65
+
66
+static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
67
+ FrameDescriptor *desc)
68
+{
69
+ const uint32_t nxt = desc->next;
70
+ allwinner_sun8i_emac_get_desc(s, desc, nxt);
71
+ return nxt;
72
+}
73
+
74
+static uint32_t allwinner_sun8i_emac_find_desc(AwSun8iEmacState *s,
75
+ FrameDescriptor *desc,
76
+ uint32_t start_addr,
77
+ size_t min_size)
78
{
55
{
79
uint32_t desc_addr = start_addr;
56
int level;
80
57
int n;
81
/* Note that the list is a cycle. Last entry points back to the head. */
58
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_update(stellaris_adc_state *s)
82
while (desc_addr != 0) {
59
83
- dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc));
60
static void stellaris_adc_trigger(void *opaque, int irq, int level)
84
+ allwinner_sun8i_emac_get_desc(s, desc, desc_addr);
85
86
- if ((desc->status & DESC_STATUS_CTL) &&
87
- (desc->status2 & DESC_STATUS2_BUF_SIZE_MASK) >= min_size) {
88
+ if (allwinner_sun8i_emac_desc_owned(desc, min_size)) {
89
return desc_addr;
90
} else if (desc->next == start_addr) {
91
break;
92
@@ -XXX,XX +XXX,XX @@ static uint32_t allwinner_sun8i_emac_rx_desc(AwSun8iEmacState *s,
93
FrameDescriptor *desc,
94
size_t min_size)
95
{
61
{
96
- return allwinner_sun8i_emac_get_desc(s, desc, s->rx_desc_curr, min_size);
62
- stellaris_adc_state *s = opaque;
97
+ return allwinner_sun8i_emac_find_desc(s, desc, s->rx_desc_curr, min_size);
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
}
98
}
69
}
99
70
100
static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
71
-static void stellaris_adc_reset(stellaris_adc_state *s)
101
- FrameDescriptor *desc,
72
+static void stellaris_adc_reset(StellarisADCState *s)
102
- size_t min_size)
103
+ FrameDescriptor *desc)
104
{
73
{
105
- return allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_head, min_size);
74
int n;
106
+ allwinner_sun8i_emac_get_desc(s, desc, s->tx_desc_curr);
75
107
+ return s->tx_desc_curr;
76
@@ -XXX,XX +XXX,XX @@ static void stellaris_adc_reset(stellaris_adc_state *s)
108
}
77
static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
109
78
unsigned size)
110
static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
79
{
111
@@ -XXX,XX +XXX,XX @@ static ssize_t allwinner_sun8i_emac_receive(NetClientState *nc,
80
- stellaris_adc_state *s = opaque;
112
bytes_left -= desc_bytes;
81
+ StellarisADCState *s = opaque;
113
82
114
/* Move to the next descriptor */
83
/* TODO: Implement this. */
115
- s->rx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 64);
84
if (offset >= 0x40 && offset < 0xc0) {
116
+ s->rx_desc_curr = allwinner_sun8i_emac_find_desc(s, &desc, desc.next,
85
@@ -XXX,XX +XXX,XX @@ static uint64_t stellaris_adc_read(void *opaque, hwaddr offset,
117
+ AW_SUN8I_EMAC_MIN_PKT_SZ);
86
static void stellaris_adc_write(void *opaque, hwaddr offset,
118
if (!s->rx_desc_curr) {
87
uint64_t value, unsigned size)
119
/* Not enough buffer space available */
88
{
120
s->int_sta |= INT_STA_RX_BUF_UA;
89
- stellaris_adc_state *s = opaque;
121
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s)
90
+ StellarisADCState *s = opaque;
122
size_t transmitted = 0;
91
123
static uint8_t packet_buf[2048];
92
/* TODO: Implement this. */
124
93
if (offset >= 0x40 && offset < 0xc0) {
125
- s->tx_desc_curr = allwinner_sun8i_emac_tx_desc(s, &desc, 0);
94
@@ -XXX,XX +XXX,XX @@ static const VMStateDescription vmstate_stellaris_adc = {
126
+ s->tx_desc_curr = allwinner_sun8i_emac_tx_desc(s, &desc);
95
.version_id = 1,
127
96
.minimum_version_id = 1,
128
/* Read all transmit descriptors */
97
.fields = (VMStateField[]) {
129
- while (s->tx_desc_curr != 0) {
98
- VMSTATE_UINT32(actss, stellaris_adc_state),
130
+ while (allwinner_sun8i_emac_desc_owned(&desc, 0)) {
99
- VMSTATE_UINT32(ris, stellaris_adc_state),
131
100
- VMSTATE_UINT32(im, stellaris_adc_state),
132
/* Read from physical memory into packet buffer */
101
- VMSTATE_UINT32(emux, stellaris_adc_state),
133
bytes = desc.status2 & DESC_STATUS2_BUF_SIZE_MASK;
102
- VMSTATE_UINT32(ostat, stellaris_adc_state),
134
@@ -XXX,XX +XXX,XX @@ static void allwinner_sun8i_emac_transmit(AwSun8iEmacState *s)
103
- VMSTATE_UINT32(ustat, stellaris_adc_state),
135
packet_bytes = 0;
104
- VMSTATE_UINT32(sspri, stellaris_adc_state),
136
transmitted++;
105
- VMSTATE_UINT32(sac, stellaris_adc_state),
137
}
106
- VMSTATE_UINT32(fifo[0].state, stellaris_adc_state),
138
- s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc, 0);
107
- VMSTATE_UINT32_ARRAY(fifo[0].data, stellaris_adc_state, 16),
139
+ s->tx_desc_curr = allwinner_sun8i_emac_next_desc(s, &desc);
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()
140
}
149
}
141
150
};
142
/* Raise transmit completed interrupt */
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
};
143
--
169
--
144
2.20.1
170
2.34.1
145
171
146
172
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Wrote too much with low-half zip (zip1) with vl % 512 != 0.
3
The typedef and definitions are generated by the OBJECT_DECLARE_TYPE
4
macro in "hw/arm/bcm2836.h":
4
5
5
Adjust all of the x + (y << s) to x | (y << s) as a style fix.
6
20 #define TYPE_BCM283X "bcm283x"
7
21 OBJECT_DECLARE_TYPE(BCM283XState, BCM283XClass, BCM283X)
6
8
7
We only ever have exact overlap between D, M, and N. Therefore
9
The script ran in commit a489d1951c ("Use OBJECT_DECLARE_TYPE when
8
we only need a single temporary, and we do not need to check for
10
possible") missed them because they are declared in a different
9
partial overlap.
11
file unit. Remove them.
10
12
11
Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
13
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
12
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
13
Message-id: 20210309155305.11301-3-richard.henderson@linaro.org
15
Message-id: 20230109140306.23161-10-philmd@linaro.org
14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
17
---
17
target/arm/sve_helper.c | 25 ++++++++++++++-----------
18
hw/arm/bcm2836.c | 9 ++-------
18
1 file changed, 14 insertions(+), 11 deletions(-)
19
1 file changed, 2 insertions(+), 7 deletions(-)
19
20
20
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
21
diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c
21
index XXXXXXX..XXXXXXX 100644
22
index XXXXXXX..XXXXXXX 100644
22
--- a/target/arm/sve_helper.c
23
--- a/hw/arm/bcm2836.c
23
+++ b/target/arm/sve_helper.c
24
+++ b/hw/arm/bcm2836.c
24
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
25
@@ -XXX,XX +XXX,XX @@
25
intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
26
#include "hw/arm/raspi_platform.h"
26
int esz = FIELD_EX32(pred_desc, PREDDESC, ESZ);
27
#include "hw/sysbus.h"
27
intptr_t high = FIELD_EX32(pred_desc, PREDDESC, DATA);
28
28
+ int esize = 1 << esz;
29
-typedef struct BCM283XClass {
29
uint64_t *d = vd;
30
+struct BCM283XClass {
30
intptr_t i;
31
/*< private >*/
31
32
DeviceClass parent_class;
32
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
33
/*< public >*/
33
mm = extract64(mm, high * half, half);
34
@@ -XXX,XX +XXX,XX @@ typedef struct BCM283XClass {
34
nn = expand_bits(nn, esz);
35
hwaddr peri_base; /* Peripheral base address seen by the CPU */
35
mm = expand_bits(mm, esz);
36
hwaddr ctrl_base; /* Interrupt controller and mailboxes etc. */
36
- d[0] = nn + (mm << (1 << esz));
37
int clusterid;
37
+ d[0] = nn | (mm << esize);
38
-} BCM283XClass;
38
} else {
39
-
39
- ARMPredicateReg tmp_n, tmp_m;
40
-#define BCM283X_CLASS(klass) \
40
+ ARMPredicateReg tmp;
41
- OBJECT_CLASS_CHECK(BCM283XClass, (klass), TYPE_BCM283X)
41
42
-#define BCM283X_GET_CLASS(obj) \
42
/* We produce output faster than we consume input.
43
- OBJECT_GET_CLASS(BCM283XClass, (obj), TYPE_BCM283X)
43
Therefore we must be mindful of possible overlap. */
44
+};
44
- if ((vn - vd) < (uintptr_t)oprsz) {
45
45
- vn = memcpy(&tmp_n, vn, oprsz);
46
static Property bcm2836_enabled_cores_property =
46
- }
47
DEFINE_PROP_UINT32("enabled-cpus", BCM283XState, enabled_cpus, 0);
47
- if ((vm - vd) < (uintptr_t)oprsz) {
48
- vm = memcpy(&tmp_m, vm, oprsz);
49
+ if (vd == vn) {
50
+ vn = memcpy(&tmp, vn, oprsz);
51
+ if (vd == vm) {
52
+ vm = vn;
53
+ }
54
+ } else if (vd == vm) {
55
+ vm = memcpy(&tmp, vm, oprsz);
56
}
57
if (high) {
58
high = oprsz >> 1;
59
}
60
61
- if ((high & 3) == 0) {
62
+ if ((oprsz & 7) == 0) {
63
uint32_t *n = vn, *m = vm;
64
high >>= 2;
65
66
- for (i = 0; i < DIV_ROUND_UP(oprsz, 8); i++) {
67
+ for (i = 0; i < oprsz / 8; i++) {
68
uint64_t nn = n[H4(high + i)];
69
uint64_t mm = m[H4(high + i)];
70
71
nn = expand_bits(nn, esz);
72
mm = expand_bits(mm, esz);
73
- d[i] = nn + (mm << (1 << esz));
74
+ d[i] = nn | (mm << esize);
75
}
76
} else {
77
uint8_t *n = vn, *m = vm;
78
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_zip_p)(void *vd, void *vn, void *vm, uint32_t pred_desc)
79
80
nn = expand_bits(nn, esz);
81
mm = expand_bits(mm, esz);
82
- d16[H2(i)] = nn + (mm << (1 << esz));
83
+ d16[H2(i)] = nn | (mm << esize);
84
}
85
}
86
}
87
--
48
--
88
2.20.1
49
2.34.1
89
50
90
51
diff view generated by jsdifflib
1
From: Hao Wu <wuhaotsh@google.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
This patch adds fan_splitters (split IRQs) in NPCM7XX boards. Each fan
3
NPCM7XX models have been commited after the conversion from
4
splitter corresponds to 1 PWM output and can connect to multiple fan
4
commit 8063396bf3 ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible").
5
inputs (MFT devices).
5
Manually convert them.
6
In NPCM7XX boards(NPCM750 EVB and Quanta GSJ boards), we initializes
6
7
these splitters and connect them to their corresponding modules
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
according their specific device trees.
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
9
Message-id: 20230109140306.23161-11-philmd@linaro.org
10
Reviewed-by: Doug Evans <dje@google.com>
11
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
12
Signed-off-by: Hao Wu <wuhaotsh@google.com>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
14
Message-id: 20210311180855.149764-5-wuhaotsh@google.com
15
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
16
---
11
---
17
include/hw/arm/npcm7xx.h | 11 ++++-
12
include/hw/adc/npcm7xx_adc.h | 7 +++----
18
hw/arm/npcm7xx_boards.c | 99 ++++++++++++++++++++++++++++++++++++++++
13
include/hw/arm/npcm7xx.h | 18 ++++++------------
19
2 files changed, 109 insertions(+), 1 deletion(-)
14
include/hw/i2c/npcm7xx_smbus.h | 7 +++----
20
15
include/hw/misc/npcm7xx_clk.h | 2 +-
16
include/hw/misc/npcm7xx_gcr.h | 6 +++---
17
include/hw/misc/npcm7xx_mft.h | 7 +++----
18
include/hw/misc/npcm7xx_pwm.h | 3 +--
19
include/hw/misc/npcm7xx_rng.h | 6 +++---
20
include/hw/net/npcm7xx_emc.h | 5 +----
21
include/hw/sd/npcm7xx_sdhci.h | 4 ++--
22
10 files changed, 26 insertions(+), 39 deletions(-)
23
24
diff --git a/include/hw/adc/npcm7xx_adc.h b/include/hw/adc/npcm7xx_adc.h
25
index XXXXXXX..XXXXXXX 100644
26
--- a/include/hw/adc/npcm7xx_adc.h
27
+++ b/include/hw/adc/npcm7xx_adc.h
28
@@ -XXX,XX +XXX,XX @@
29
* @iref: The internal reference voltage, initialized at launch time.
30
* @rv: The calibrated output values of 0.5V and 1.5V for the ADC.
31
*/
32
-typedef struct {
33
+struct NPCM7xxADCState {
34
SysBusDevice parent;
35
36
MemoryRegion iomem;
37
@@ -XXX,XX +XXX,XX @@ typedef struct {
38
uint32_t iref;
39
40
uint16_t calibration_r_values[NPCM7XX_ADC_NUM_CALIB];
41
-} NPCM7xxADCState;
42
+};
43
44
#define TYPE_NPCM7XX_ADC "npcm7xx-adc"
45
-#define NPCM7XX_ADC(obj) \
46
- OBJECT_CHECK(NPCM7xxADCState, (obj), TYPE_NPCM7XX_ADC)
47
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxADCState, NPCM7XX_ADC)
48
49
#endif /* NPCM7XX_ADC_H */
21
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
50
diff --git a/include/hw/arm/npcm7xx.h b/include/hw/arm/npcm7xx.h
22
index XXXXXXX..XXXXXXX 100644
51
index XXXXXXX..XXXXXXX 100644
23
--- a/include/hw/arm/npcm7xx.h
52
--- a/include/hw/arm/npcm7xx.h
24
+++ b/include/hw/arm/npcm7xx.h
53
+++ b/include/hw/arm/npcm7xx.h
25
@@ -XXX,XX +XXX,XX @@
54
@@ -XXX,XX +XXX,XX @@
26
55
27
#include "hw/boards.h"
56
#define NPCM7XX_NR_PWM_MODULES 2
28
#include "hw/adc/npcm7xx_adc.h"
57
29
+#include "hw/core/split-irq.h"
58
-typedef struct NPCM7xxMachine {
30
#include "hw/cpu/a9mpcore.h"
59
+struct NPCM7xxMachine {
31
#include "hw/gpio/npcm7xx_gpio.h"
32
#include "hw/i2c/npcm7xx_smbus.h"
33
@@ -XXX,XX +XXX,XX @@
34
#define NPCM7XX_GIC_CPU_IF_ADDR (0xf03fe100) /* GIC within A9 */
35
#define NPCM7XX_BOARD_SETUP_ADDR (0xffff1000) /* Boot ROM */
36
37
+#define NPCM7XX_NR_PWM_MODULES 2
38
+
39
typedef struct NPCM7xxMachine {
40
MachineState parent;
60
MachineState parent;
41
+ /*
61
/*
42
+ * PWM fan splitter. each splitter connects to one PWM output and
62
* PWM fan splitter. each splitter connects to one PWM output and
43
+ * multiple MFT inputs.
63
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMachine {
44
+ */
64
*/
45
+ SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES *
65
SplitIRQ fan_splitter[NPCM7XX_NR_PWM_MODULES *
46
+ NPCM7XX_PWM_PER_MODULE];
66
NPCM7XX_PWM_PER_MODULE];
47
} NPCM7xxMachine;
67
-} NPCM7xxMachine;
68
+};
48
69
49
#define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
70
#define TYPE_NPCM7XX_MACHINE MACHINE_TYPE_NAME("npcm7xx")
71
-#define NPCM7XX_MACHINE(obj) \
72
- OBJECT_CHECK(NPCM7xxMachine, (obj), TYPE_NPCM7XX_MACHINE)
73
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMachine, NPCM7XX_MACHINE)
74
75
typedef struct NPCM7xxMachineClass {
76
MachineClass parent;
77
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMachineClass {
78
#define NPCM7XX_MACHINE_GET_CLASS(obj) \
79
OBJECT_GET_CLASS(NPCM7xxMachineClass, (obj), TYPE_NPCM7XX_MACHINE)
80
81
-typedef struct NPCM7xxState {
82
+struct NPCM7xxState {
83
DeviceState parent;
84
85
ARMCPU cpu[NPCM7XX_MAX_NUM_CPUS];
50
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState {
86
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxState {
51
NPCM7xxCLKState clk;
87
NPCM7xxFIUState fiu[2];
52
NPCM7xxTimerCtrlState tim[3];
88
NPCM7xxEMCState emc[2];
53
NPCM7xxADCState adc;
89
NPCM7xxSDHCIState mmc;
54
- NPCM7xxPWMState pwm[2];
90
-} NPCM7xxState;
55
+ NPCM7xxPWMState pwm[NPCM7XX_NR_PWM_MODULES];
91
+};
56
NPCM7xxMFTState mft[8];
92
57
NPCM7xxOTPState key_storage;
93
#define TYPE_NPCM7XX "npcm7xx"
58
NPCM7xxOTPState fuse_array;
94
-#define NPCM7XX(obj) OBJECT_CHECK(NPCM7xxState, (obj), TYPE_NPCM7XX)
59
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
95
+OBJECT_DECLARE_TYPE(NPCM7xxState, NPCM7xxClass, NPCM7XX)
60
index XXXXXXX..XXXXXXX 100644
96
61
--- a/hw/arm/npcm7xx_boards.c
97
#define TYPE_NPCM730 "npcm730"
62
+++ b/hw/arm/npcm7xx_boards.c
98
#define TYPE_NPCM750 "npcm750"
63
@@ -XXX,XX +XXX,XX @@
99
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxClass {
64
#include "hw/core/cpu.h"
100
uint32_t num_cpus;
65
#include "hw/i2c/smbus_eeprom.h"
101
} NPCM7xxClass;
66
#include "hw/loader.h"
102
67
+#include "hw/qdev-core.h"
103
-#define NPCM7XX_CLASS(klass) \
68
#include "hw/qdev-properties.h"
104
- OBJECT_CLASS_CHECK(NPCM7xxClass, (klass), TYPE_NPCM7XX)
69
#include "qapi/error.h"
105
-#define NPCM7XX_GET_CLASS(obj) \
70
#include "qemu-common.h"
106
- OBJECT_GET_CLASS(NPCM7xxClass, (obj), TYPE_NPCM7XX)
71
@@ -XXX,XX +XXX,XX @@ static void at24c_eeprom_init(NPCM7xxState *soc, int bus, uint8_t addr,
107
-
72
i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort);
108
/**
73
}
109
* npcm7xx_load_kernel - Loads memory with everything needed to boot
74
110
* @machine - The machine containing the SoC to be booted.
75
+static void npcm7xx_init_pwm_splitter(NPCM7xxMachine *machine,
111
diff --git a/include/hw/i2c/npcm7xx_smbus.h b/include/hw/i2c/npcm7xx_smbus.h
76
+ NPCM7xxState *soc, const int *fan_counts)
112
index XXXXXXX..XXXXXXX 100644
77
+{
113
--- a/include/hw/i2c/npcm7xx_smbus.h
78
+ SplitIRQ *splitters = machine->fan_splitter;
114
+++ b/include/hw/i2c/npcm7xx_smbus.h
79
+
115
@@ -XXX,XX +XXX,XX @@ typedef enum NPCM7xxSMBusStatus {
80
+ /*
116
* @rx_cur: The current position of rx_fifo.
81
+ * PWM 0~3 belong to module 0 output 0~3.
117
* @status: The current status of the SMBus.
82
+ * PWM 4~7 belong to module 1 output 0~3.
118
*/
83
+ */
119
-typedef struct NPCM7xxSMBusState {
84
+ for (int i = 0; i < NPCM7XX_NR_PWM_MODULES; ++i) {
120
+struct NPCM7xxSMBusState {
85
+ for (int j = 0; j < NPCM7XX_PWM_PER_MODULE; ++j) {
121
SysBusDevice parent;
86
+ int splitter_no = i * NPCM7XX_PWM_PER_MODULE + j;
122
87
+ DeviceState *splitter;
123
MemoryRegion iomem;
88
+
124
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxSMBusState {
89
+ if (fan_counts[splitter_no] < 1) {
125
uint8_t rx_cur;
90
+ continue;
126
91
+ }
127
NPCM7xxSMBusStatus status;
92
+ object_initialize_child(OBJECT(machine), "fan-splitter[*]",
128
-} NPCM7xxSMBusState;
93
+ &splitters[splitter_no], TYPE_SPLIT_IRQ);
129
+};
94
+ splitter = DEVICE(&splitters[splitter_no]);
130
95
+ qdev_prop_set_uint16(splitter, "num-lines",
131
#define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus"
96
+ fan_counts[splitter_no]);
132
-#define NPCM7XX_SMBUS(obj) OBJECT_CHECK(NPCM7xxSMBusState, (obj), \
97
+ qdev_realize(splitter, NULL, &error_abort);
133
- TYPE_NPCM7XX_SMBUS)
98
+ qdev_connect_gpio_out_named(DEVICE(&soc->pwm[i]), "duty-gpio-out",
134
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxSMBusState, NPCM7XX_SMBUS)
99
+ j, qdev_get_gpio_in(splitter, 0));
135
100
+ }
136
#endif /* NPCM7XX_SMBUS_H */
101
+ }
137
diff --git a/include/hw/misc/npcm7xx_clk.h b/include/hw/misc/npcm7xx_clk.h
102
+}
138
index XXXXXXX..XXXXXXX 100644
103
+
139
--- a/include/hw/misc/npcm7xx_clk.h
104
+static void npcm7xx_connect_pwm_fan(NPCM7xxState *soc, SplitIRQ *splitter,
140
+++ b/include/hw/misc/npcm7xx_clk.h
105
+ int fan_no, int output_no)
141
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxCLKState {
106
+{
142
};
107
+ DeviceState *fan;
143
108
+ int fan_input;
144
#define TYPE_NPCM7XX_CLK "npcm7xx-clk"
109
+ qemu_irq fan_duty_gpio;
145
-#define NPCM7XX_CLK(obj) OBJECT_CHECK(NPCM7xxCLKState, (obj), TYPE_NPCM7XX_CLK)
110
+
146
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxCLKState, NPCM7XX_CLK)
111
+ g_assert(fan_no >= 0 && fan_no <= NPCM7XX_MFT_MAX_FAN_INPUT);
147
112
+ /*
148
#endif /* NPCM7XX_CLK_H */
113
+ * Fan 0~1 belong to module 0 input 0~1.
149
diff --git a/include/hw/misc/npcm7xx_gcr.h b/include/hw/misc/npcm7xx_gcr.h
114
+ * Fan 2~3 belong to module 1 input 0~1.
150
index XXXXXXX..XXXXXXX 100644
115
+ * ...
151
--- a/include/hw/misc/npcm7xx_gcr.h
116
+ * Fan 14~15 belong to module 7 input 0~1.
152
+++ b/include/hw/misc/npcm7xx_gcr.h
117
+ * Fan 16~17 belong to module 0 input 2~3.
153
@@ -XXX,XX +XXX,XX @@
118
+ * Fan 18~19 belong to module 1 input 2~3.
154
*/
119
+ */
155
#define NPCM7XX_GCR_NR_REGS (0x148 / sizeof(uint32_t))
120
+ if (fan_no < 16) {
156
121
+ fan = DEVICE(&soc->mft[fan_no / 2]);
157
-typedef struct NPCM7xxGCRState {
122
+ fan_input = fan_no % 2;
158
+struct NPCM7xxGCRState {
123
+ } else {
159
SysBusDevice parent;
124
+ fan = DEVICE(&soc->mft[(fan_no - 16) / 2]);
160
125
+ fan_input = fan_no % 2 + 2;
161
MemoryRegion iomem;
126
+ }
162
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxGCRState {
127
+
163
uint32_t reset_pwron;
128
+ /* Connect the Fan to PWM module */
164
uint32_t reset_mdlr;
129
+ fan_duty_gpio = qdev_get_gpio_in_named(fan, "duty", fan_input);
165
uint32_t reset_intcr3;
130
+ qdev_connect_gpio_out(DEVICE(splitter), output_no, fan_duty_gpio);
166
-} NPCM7xxGCRState;
131
+}
167
+};
132
+
168
133
static void npcm750_evb_i2c_init(NPCM7xxState *soc)
169
#define TYPE_NPCM7XX_GCR "npcm7xx-gcr"
134
{
170
-#define NPCM7XX_GCR(obj) OBJECT_CHECK(NPCM7xxGCRState, (obj), TYPE_NPCM7XX_GCR)
135
/* lm75 temperature sensor on SVB, tmp105 is compatible */
171
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxGCRState, NPCM7XX_GCR)
136
@@ -XXX,XX +XXX,XX @@ static void npcm750_evb_i2c_init(NPCM7xxState *soc)
172
137
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48);
173
#endif /* NPCM7XX_GCR_H */
138
}
174
diff --git a/include/hw/misc/npcm7xx_mft.h b/include/hw/misc/npcm7xx_mft.h
139
175
index XXXXXXX..XXXXXXX 100644
140
+static void npcm750_evb_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc)
176
--- a/include/hw/misc/npcm7xx_mft.h
141
+{
177
+++ b/include/hw/misc/npcm7xx_mft.h
142
+ SplitIRQ *splitter = machine->fan_splitter;
178
@@ -XXX,XX +XXX,XX @@
143
+ static const int fan_counts[] = {2, 2, 2, 2, 2, 2, 2, 2};
179
* @max_rpm: The maximum rpm for fans. Order: A0, B0, A1, B1.
144
+
180
* @duty: The duty cycles for fans, relative to NPCM7XX_PWM_MAX_DUTY.
145
+ npcm7xx_init_pwm_splitter(machine, soc, fan_counts);
181
*/
146
+ npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x00, 0);
182
-typedef struct NPCM7xxMFTState {
147
+ npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x01, 1);
183
+struct NPCM7xxMFTState {
148
+ npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x02, 0);
184
SysBusDevice parent;
149
+ npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x03, 1);
185
150
+ npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x04, 0);
186
MemoryRegion iomem;
151
+ npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x05, 1);
187
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxMFTState {
152
+ npcm7xx_connect_pwm_fan(soc, &splitter[3], 0x06, 0);
188
153
+ npcm7xx_connect_pwm_fan(soc, &splitter[3], 0x07, 1);
189
uint32_t max_rpm[NPCM7XX_MFT_FANIN_COUNT];
154
+ npcm7xx_connect_pwm_fan(soc, &splitter[4], 0x08, 0);
190
uint32_t duty[NPCM7XX_MFT_FANIN_COUNT];
155
+ npcm7xx_connect_pwm_fan(soc, &splitter[4], 0x09, 1);
191
-} NPCM7xxMFTState;
156
+ npcm7xx_connect_pwm_fan(soc, &splitter[5], 0x0a, 0);
192
+};
157
+ npcm7xx_connect_pwm_fan(soc, &splitter[5], 0x0b, 1);
193
158
+ npcm7xx_connect_pwm_fan(soc, &splitter[6], 0x0c, 0);
194
#define TYPE_NPCM7XX_MFT "npcm7xx-mft"
159
+ npcm7xx_connect_pwm_fan(soc, &splitter[6], 0x0d, 1);
195
-#define NPCM7XX_MFT(obj) \
160
+ npcm7xx_connect_pwm_fan(soc, &splitter[7], 0x0e, 0);
196
- OBJECT_CHECK(NPCM7xxMFTState, (obj), TYPE_NPCM7XX_MFT)
161
+ npcm7xx_connect_pwm_fan(soc, &splitter[7], 0x0f, 1);
197
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxMFTState, NPCM7XX_MFT)
162
+}
198
163
+
199
#endif /* NPCM7XX_MFT_H */
164
static void quanta_gsj_i2c_init(NPCM7xxState *soc)
200
diff --git a/include/hw/misc/npcm7xx_pwm.h b/include/hw/misc/npcm7xx_pwm.h
165
{
201
index XXXXXXX..XXXXXXX 100644
166
/* GSJ machine have 4 max31725 temperature sensors, tmp105 is compatible. */
202
--- a/include/hw/misc/npcm7xx_pwm.h
167
@@ -XXX,XX +XXX,XX @@ static void quanta_gsj_i2c_init(NPCM7xxState *soc)
203
+++ b/include/hw/misc/npcm7xx_pwm.h
168
/* TODO: Add additional i2c devices. */
204
@@ -XXX,XX +XXX,XX @@ struct NPCM7xxPWMState {
169
}
205
};
170
206
171
+static void quanta_gsj_fan_init(NPCM7xxMachine *machine, NPCM7xxState *soc)
207
#define TYPE_NPCM7XX_PWM "npcm7xx-pwm"
172
+{
208
-#define NPCM7XX_PWM(obj) \
173
+ SplitIRQ *splitter = machine->fan_splitter;
209
- OBJECT_CHECK(NPCM7xxPWMState, (obj), TYPE_NPCM7XX_PWM)
174
+ static const int fan_counts[] = {2, 2, 2, 0, 0, 0, 0, 0};
210
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxPWMState, NPCM7XX_PWM)
175
+
211
176
+ npcm7xx_init_pwm_splitter(machine, soc, fan_counts);
212
#endif /* NPCM7XX_PWM_H */
177
+ npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x00, 0);
213
diff --git a/include/hw/misc/npcm7xx_rng.h b/include/hw/misc/npcm7xx_rng.h
178
+ npcm7xx_connect_pwm_fan(soc, &splitter[0], 0x01, 1);
214
index XXXXXXX..XXXXXXX 100644
179
+ npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x02, 0);
215
--- a/include/hw/misc/npcm7xx_rng.h
180
+ npcm7xx_connect_pwm_fan(soc, &splitter[1], 0x03, 1);
216
+++ b/include/hw/misc/npcm7xx_rng.h
181
+ npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x04, 0);
217
@@ -XXX,XX +XXX,XX @@
182
+ npcm7xx_connect_pwm_fan(soc, &splitter[2], 0x05, 1);
218
183
+}
219
#include "hw/sysbus.h"
184
+
220
185
static void npcm750_evb_init(MachineState *machine)
221
-typedef struct NPCM7xxRNGState {
186
{
222
+struct NPCM7xxRNGState {
187
NPCM7xxState *soc;
223
SysBusDevice parent;
188
@@ -XXX,XX +XXX,XX @@ static void npcm750_evb_init(MachineState *machine)
224
189
npcm7xx_load_bootrom(machine, soc);
225
MemoryRegion iomem;
190
npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", drive_get(IF_MTD, 0, 0));
226
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxRNGState {
191
npcm750_evb_i2c_init(soc);
227
uint8_t rngcs;
192
+ npcm750_evb_fan_init(NPCM7XX_MACHINE(machine), soc);
228
uint8_t rngd;
193
npcm7xx_load_kernel(machine, soc);
229
uint8_t rngmode;
194
}
230
-} NPCM7xxRNGState;
195
231
+};
196
@@ -XXX,XX +XXX,XX @@ static void quanta_gsj_init(MachineState *machine)
232
197
npcm7xx_connect_flash(&soc->fiu[0], 0, "mx25l25635e",
233
#define TYPE_NPCM7XX_RNG "npcm7xx-rng"
198
drive_get(IF_MTD, 0, 0));
234
-#define NPCM7XX_RNG(obj) OBJECT_CHECK(NPCM7xxRNGState, (obj), TYPE_NPCM7XX_RNG)
199
quanta_gsj_i2c_init(soc);
235
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxRNGState, NPCM7XX_RNG)
200
+ quanta_gsj_fan_init(NPCM7XX_MACHINE(machine), soc);
236
201
npcm7xx_load_kernel(machine, soc);
237
#endif /* NPCM7XX_RNG_H */
202
}
238
diff --git a/include/hw/net/npcm7xx_emc.h b/include/hw/net/npcm7xx_emc.h
203
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;
244
};
245
246
-typedef struct NPCM7xxEMCState NPCM7xxEMCState;
247
-
248
#define TYPE_NPCM7XX_EMC "npcm7xx-emc"
249
-#define NPCM7XX_EMC(obj) \
250
- OBJECT_CHECK(NPCM7xxEMCState, (obj), TYPE_NPCM7XX_EMC)
251
+OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxEMCState, NPCM7XX_EMC)
252
253
#endif /* NPCM7XX_EMC_H */
254
diff --git a/include/hw/sd/npcm7xx_sdhci.h b/include/hw/sd/npcm7xx_sdhci.h
255
index XXXXXXX..XXXXXXX 100644
256
--- a/include/hw/sd/npcm7xx_sdhci.h
257
+++ b/include/hw/sd/npcm7xx_sdhci.h
258
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxRegs {
259
uint32_t boottoctrl;
260
} NPCM7xxRegisters;
261
262
-typedef struct NPCM7xxSDHCIState {
263
+struct NPCM7xxSDHCIState {
264
SysBusDevice parent;
265
266
MemoryRegion container;
267
@@ -XXX,XX +XXX,XX @@ typedef struct NPCM7xxSDHCIState {
268
NPCM7xxRegisters regs;
269
270
SDHCIState sdhci;
271
-} NPCM7xxSDHCIState;
272
+};
273
274
#endif /* NPCM7XX_SDHCI_H */
204
--
275
--
205
2.20.1
276
2.34.1
206
277
207
278
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Unmap notifiers work with an address mask assuming an
3
The structure is named SECUREECState. Rename the type accordingly.
4
invalidation range of a power of 2. Nothing mandates this
5
in the VIRTIO-IOMMU spec.
6
4
7
So in case the range is not a power of 2, split it into
5
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
8
several invalidations.
6
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
9
7
Message-id: 20230109140306.23161-12-philmd@linaro.org
10
Signed-off-by: Eric Auger <eric.auger@redhat.com>
11
Reviewed-by: Peter Xu <peterx@redhat.com>
12
Message-id: 20210309102742.30442-4-eric.auger@redhat.com
13
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
---
9
---
15
hw/virtio/virtio-iommu.c | 19 ++++++++++++++++---
10
hw/misc/sbsa_ec.c | 13 +++++++------
16
1 file changed, 16 insertions(+), 3 deletions(-)
11
1 file changed, 7 insertions(+), 6 deletions(-)
17
12
18
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
13
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
19
index XXXXXXX..XXXXXXX 100644
14
index XXXXXXX..XXXXXXX 100644
20
--- a/hw/virtio/virtio-iommu.c
15
--- a/hw/misc/sbsa_ec.c
21
+++ b/hw/virtio/virtio-iommu.c
16
+++ b/hw/misc/sbsa_ec.c
22
@@ -XXX,XX +XXX,XX @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start,
17
@@ -XXX,XX +XXX,XX @@
23
hwaddr virt_end)
18
#include "hw/sysbus.h"
19
#include "sysemu/runstate.h"
20
21
-typedef struct {
22
+typedef struct SECUREECState {
23
SysBusDevice parent_obj;
24
MemoryRegion iomem;
25
} SECUREECState;
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)
36
}
37
38
static void sbsa_ec_write(void *opaque, hwaddr offset,
39
- uint64_t value, unsigned size)
40
+ uint64_t value, unsigned size)
24
{
41
{
25
IOMMUTLBEvent event;
42
if (offset == 0) { /* PSCI machine power command register */
26
+ uint64_t delta = virt_end - virt_start;
43
switch (value) {
27
44
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps sbsa_ec_ops = {
28
if (!(mr->iommu_notify_flags & IOMMU_NOTIFIER_UNMAP)) {
45
29
return;
46
static void sbsa_ec_init(Object *obj)
30
@@ -XXX,XX +XXX,XX @@ static void virtio_iommu_notify_unmap(IOMMUMemoryRegion *mr, hwaddr virt_start,
47
{
31
48
- SECUREECState *s = SECURE_EC(obj);
32
event.type = IOMMU_NOTIFIER_UNMAP;
49
+ SECUREECState *s = SBSA_SECURE_EC(obj);
33
event.entry.target_as = &address_space_memory;
50
SysBusDevice *dev = SYS_BUS_DEVICE(obj);
34
- event.entry.addr_mask = virt_end - virt_start;
51
35
- event.entry.iova = virt_start;
52
memory_region_init_io(&s->iomem, obj, &sbsa_ec_ops, s, "sbsa-ec",
36
event.entry.perm = IOMMU_NONE;
53
@@ -XXX,XX +XXX,XX @@ static void sbsa_ec_class_init(ObjectClass *klass, void *data)
37
event.entry.translated_addr = 0;
38
+ event.entry.addr_mask = delta;
39
+ event.entry.iova = virt_start;
40
41
- memory_region_notify_iommu(mr, 0, event);
42
+ if (delta == UINT64_MAX) {
43
+ memory_region_notify_iommu(mr, 0, event);
44
+ }
45
+
46
+
47
+ while (virt_start != virt_end + 1) {
48
+ uint64_t mask = dma_aligned_pow2_mask(virt_start, virt_end, 64);
49
+
50
+ event.entry.addr_mask = mask;
51
+ event.entry.iova = virt_start;
52
+ memory_region_notify_iommu(mr, 0, event);
53
+ virt_start += mask + 1;
54
+ }
55
}
54
}
56
55
57
static gboolean virtio_iommu_notify_unmap_cb(gpointer key, gpointer value,
56
static const TypeInfo sbsa_ec_info = {
57
- .name = TYPE_SBSA_EC,
58
+ .name = TYPE_SBSA_SECURE_EC,
59
.parent = TYPE_SYS_BUS_DEVICE,
60
.instance_size = sizeof(SECUREECState),
61
.instance_init = sbsa_ec_init,
58
--
62
--
59
2.20.1
63
2.34.1
60
64
61
65
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Convert all sid printouts to sid=0x%x.
3
This model was merged few days before the QOM cleanup from
4
commit 8063396bf3 ("Use OBJECT_DECLARE_SIMPLE_TYPE when possible")
5
was pulled and merged. Manually adapt.
4
6
5
Signed-off-by: Eric Auger <eric.auger@redhat.com>
7
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
8
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
7
Message-id: 20210309102742.30442-8-eric.auger@redhat.com
9
Message-id: 20230109140306.23161-13-philmd@linaro.org
8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
9
---
11
---
10
hw/arm/trace-events | 24 ++++++++++++------------
12
hw/misc/sbsa_ec.c | 3 +--
11
1 file changed, 12 insertions(+), 12 deletions(-)
13
1 file changed, 1 insertion(+), 2 deletions(-)
12
14
13
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
15
diff --git a/hw/misc/sbsa_ec.c b/hw/misc/sbsa_ec.c
14
index XXXXXXX..XXXXXXX 100644
16
index XXXXXXX..XXXXXXX 100644
15
--- a/hw/arm/trace-events
17
--- a/hw/misc/sbsa_ec.c
16
+++ b/hw/arm/trace-events
18
+++ b/hw/misc/sbsa_ec.c
17
@@ -XXX,XX +XXX,XX @@ smmuv3_cmdq_opcode(const char *opcode) "<--- %s"
19
@@ -XXX,XX +XXX,XX @@ typedef struct SECUREECState {
18
smmuv3_cmdq_consume_out(uint32_t prod, uint32_t cons, uint8_t prod_wrap, uint8_t cons_wrap) "prod:%d, cons:%d, prod_wrap:%d, cons_wrap:%d "
20
} SECUREECState;
19
smmuv3_cmdq_consume_error(const char *cmd_name, uint8_t cmd_error) "Error on %s command execution: %d"
21
20
smmuv3_write_mmio(uint64_t addr, uint64_t val, unsigned size, uint32_t r) "addr: 0x%"PRIx64" val:0x%"PRIx64" size: 0x%x(%d)"
22
#define TYPE_SBSA_SECURE_EC "sbsa-ec"
21
-smmuv3_record_event(const char *type, uint32_t sid) "%s sid=%d"
23
-#define SBSA_SECURE_EC(obj) \
22
-smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "SID:0x%x features:0x%x, sid_split:0x%x"
24
- OBJECT_CHECK(SECUREECState, (obj), TYPE_SBSA_SECURE_EC)
23
+smmuv3_record_event(const char *type, uint32_t sid) "%s sid=0x%x"
25
+OBJECT_DECLARE_SIMPLE_TYPE(SECUREECState, SBSA_SECURE_EC)
24
+smmuv3_find_ste(uint16_t sid, uint32_t features, uint16_t sid_split) "sid=0x%x features:0x%x, sid_split:0x%x"
26
25
smmuv3_find_ste_2lvl(uint64_t strtab_base, uint64_t l1ptr, int l1_ste_offset, uint64_t l2ptr, int l2_ste_offset, int max_l2_ste) "strtab_base:0x%"PRIx64" l1ptr:0x%"PRIx64" l1_off:0x%x, l2ptr:0x%"PRIx64" l2_off:0x%x max_l2_ste:%d"
27
enum sbsa_ec_powerstates {
26
smmuv3_get_ste(uint64_t addr) "STE addr: 0x%"PRIx64
28
SBSA_EC_CMD_POWEROFF = 0x01,
27
-smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d"
28
-smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d STE bypass iova:0x%"PRIx64" is_write=%d"
29
-smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=%d abort on iova:0x%"PRIx64" is_write=%d"
30
-smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=%d iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x"
31
+smmuv3_translate_disable(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x bypass (smmu disabled) iova:0x%"PRIx64" is_write=%d"
32
+smmuv3_translate_bypass(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x STE bypass iova:0x%"PRIx64" is_write=%d"
33
+smmuv3_translate_abort(const char *n, uint16_t sid, uint64_t addr, bool is_write) "%s sid=0x%x abort on iova:0x%"PRIx64" is_write=%d"
34
+smmuv3_translate_success(const char *n, uint16_t sid, uint64_t iova, uint64_t translated, int perm) "%s sid=0x%x iova=0x%"PRIx64" translated=0x%"PRIx64" perm=0x%x"
35
smmuv3_get_cd(uint64_t addr) "CD addr: 0x%"PRIx64
36
smmuv3_decode_cd(uint32_t oas) "oas=%d"
37
smmuv3_decode_cd_tt(int i, uint32_t tsz, uint64_t ttb, uint32_t granule_sz, bool had) "TT[%d]:tsz:%d ttb:0x%"PRIx64" granule_sz:%d had:%d"
38
-smmuv3_cmdq_cfgi_ste(int streamid) "streamid =%d"
39
+smmuv3_cmdq_cfgi_ste(int streamid) "streamid= 0x%x"
40
smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%x - end=0x%x"
41
-smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d"
42
-smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)"
43
-smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)"
44
-smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid =%d asid =%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d"
45
+smmuv3_cmdq_cfgi_cd(uint32_t sid) "sid=0x%x"
46
+smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid=0x%x (hits=%d, misses=%d, hit rate=%d)"
47
+smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid=0x%x (hits=%d, misses=%d, hit rate=%d)"
48
+smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, uint8_t tg, uint64_t num_pages, uint8_t ttl, bool leaf) "vmid=%d asid=%d addr=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64" ttl=%d leaf=%d"
49
smmuv3_cmdq_tlbi_nh(void) ""
50
smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d"
51
-smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d"
52
+smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid=0x%x"
53
smmuv3_notify_flag_add(const char *iommu) "ADD SMMUNotifier node for iommu mr=%s"
54
smmuv3_notify_flag_del(const char *iommu) "DEL SMMUNotifier node for iommu mr=%s"
55
smmuv3_inv_notifiers_iova(const char *name, uint16_t asid, uint64_t iova, uint8_t tg, uint64_t num_pages) "iommu mr=%s asid=%d iova=0x%"PRIx64" tg=%d num_pages=0x%"PRIx64
56
--
29
--
57
2.20.1
30
2.34.1
58
31
59
32
diff view generated by jsdifflib
1
We're about to move code from the template header into pxa2xx_lcd.c.
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
Before doing that, make coding style fixes so checkpatch doesn't
3
complain about the patch which moves the code. This commit is
4
whitespace changes only:
5
* avoid hard-coded tabs
6
* fix ident on function prototypes
7
* no newline before open brace on array definitions
8
2
3
This remove a use of 'struct' in the DECLARE_INSTANCE_CHECKER()
4
macro call, to avoid after a QOM refactor:
5
6
hw/intc/xilinx_intc.c:45:1: error: declaration of anonymous struct must be a definition
7
DECLARE_INSTANCE_CHECKER(struct xlx_pic, XILINX_INTC,
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
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
11
Message-id: 20210211141515.8755-9-peter.maydell@linaro.org
12
---
15
---
13
hw/display/pxa2xx_template.h | 66 +++++++++++++++++-------------------
16
hw/intc/xilinx_intc.c | 28 +++++++++++++---------------
14
1 file changed, 32 insertions(+), 34 deletions(-)
17
1 file changed, 13 insertions(+), 15 deletions(-)
15
18
16
diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h
19
diff --git a/hw/intc/xilinx_intc.c b/hw/intc/xilinx_intc.c
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/display/pxa2xx_template.h
21
--- a/hw/intc/xilinx_intc.c
19
+++ b/hw/display/pxa2xx_template.h
22
+++ b/hw/intc/xilinx_intc.c
20
@@ -XXX,XX +XXX,XX @@
23
@@ -XXX,XX +XXX,XX @@
21
} while (0)
24
#define R_MAX 8
22
25
23
#ifdef HOST_WORDS_BIGENDIAN
26
#define TYPE_XILINX_INTC "xlnx.xps-intc"
24
-# define SWAP_WORDS    1
27
-DECLARE_INSTANCE_CHECKER(struct xlx_pic, XILINX_INTC,
25
+# define SWAP_WORDS 1
28
- TYPE_XILINX_INTC)
26
#endif
29
+typedef struct XpsIntc XpsIntc;
27
30
+DECLARE_INSTANCE_CHECKER(XpsIntc, XILINX_INTC, TYPE_XILINX_INTC)
28
-#define FN_2(x)        FN(x + 1) FN(x)
31
29
-#define FN_4(x)        FN_2(x + 2) FN_2(x)
32
-struct xlx_pic
30
+#define FN_2(x) FN(x + 1) FN(x)
33
+struct XpsIntc
31
+#define FN_4(x) FN_2(x + 2) FN_2(x)
32
33
-static void pxa2xx_draw_line2(void *opaque,
34
- uint8_t *dest, const uint8_t *src, int width, int deststep)
35
+static void pxa2xx_draw_line2(void *opaque, uint8_t *dest, const uint8_t *src,
36
+ int width, int deststep)
37
{
34
{
38
uint32_t *palette = opaque;
35
SysBusDevice parent_obj;
39
uint32_t data;
36
40
while (width > 0) {
37
@@ -XXX,XX +XXX,XX @@ struct xlx_pic
41
data = *(uint32_t *) src;
38
uint32_t irq_pin_state;
42
-#define FN(x)        COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]);
39
};
43
+#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 2)) & 3]);
40
44
#ifdef SWAP_WORDS
41
-static void update_irq(struct xlx_pic *p)
45
FN_4(12)
42
+static void update_irq(XpsIntc *p)
46
FN_4(8)
43
{
47
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line2(void *opaque,
44
uint32_t i;
48
}
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]);
49
}
48
}
50
49
51
-static void pxa2xx_draw_line4(void *opaque,
50
-static uint64_t
52
- uint8_t *dest, const uint8_t *src, int width, int deststep)
51
-pic_read(void *opaque, hwaddr addr, unsigned int size)
53
+static void pxa2xx_draw_line4(void *opaque, uint8_t *dest, const uint8_t *src,
52
+static uint64_t pic_read(void *opaque, hwaddr addr, unsigned int size)
54
+ int width, int deststep)
55
{
53
{
56
uint32_t *palette = opaque;
54
- struct xlx_pic *p = opaque;
57
uint32_t data;
55
+ XpsIntc *p = opaque;
58
while (width > 0) {
56
uint32_t r = 0;
59
data = *(uint32_t *) src;
57
60
-#define FN(x)        COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]);
58
addr >>= 2;
61
+#define FN(x) COPY_PIXEL(dest, palette[(data >> ((x) * 4)) & 0xf]);
59
@@ -XXX,XX +XXX,XX @@ pic_read(void *opaque, hwaddr addr, unsigned int size)
62
#ifdef SWAP_WORDS
60
return r;
63
FN_2(6)
64
FN_2(4)
65
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line4(void *opaque,
66
}
67
}
61
}
68
62
69
-static void pxa2xx_draw_line8(void *opaque,
63
-static void
70
- uint8_t *dest, const uint8_t *src, int width, int deststep)
64
-pic_write(void *opaque, hwaddr addr,
71
+static void pxa2xx_draw_line8(void *opaque, uint8_t *dest, const uint8_t *src,
65
- uint64_t val64, unsigned int size)
72
+ int width, int deststep)
66
+static void pic_write(void *opaque, hwaddr addr,
67
+ uint64_t val64, unsigned int size)
73
{
68
{
74
uint32_t *palette = opaque;
69
- struct xlx_pic *p = opaque;
75
uint32_t data;
70
+ XpsIntc *p = opaque;
76
while (width > 0) {
71
uint32_t value = val64;
77
data = *(uint32_t *) src;
72
78
-#define FN(x)        COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]);
73
addr >>= 2;
79
+#define FN(x) COPY_PIXEL(dest, palette[(data >> (x)) & 0xff]);
74
@@ -XXX,XX +XXX,XX @@ static const MemoryRegionOps pic_ops = {
80
#ifdef SWAP_WORDS
75
81
FN(24)
76
static void irq_handler(void *opaque, int irq, int level)
82
FN(16)
77
{
83
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line8(void *opaque,
78
- struct xlx_pic *p = opaque;
84
}
79
+ XpsIntc *p = opaque;
80
81
/* edge triggered interrupt */
82
if (p->c_kind_of_intr & (1 << irq) && p->regs[R_MER] & 2) {
83
@@ -XXX,XX +XXX,XX @@ static void irq_handler(void *opaque, int irq, int level)
84
85
static void xilinx_intc_init(Object *obj)
86
{
87
- struct xlx_pic *p = XILINX_INTC(obj);
88
+ XpsIntc *p = XILINX_INTC(obj);
89
90
qdev_init_gpio_in(DEVICE(obj), irq_handler, 32);
91
sysbus_init_irq(SYS_BUS_DEVICE(obj), &p->parent_irq);
92
@@ -XXX,XX +XXX,XX @@ static void xilinx_intc_init(Object *obj)
85
}
93
}
86
94
87
-static void pxa2xx_draw_line16(void *opaque,
95
static Property xilinx_intc_properties[] = {
88
- uint8_t *dest, const uint8_t *src, int width, int deststep)
96
- DEFINE_PROP_UINT32("kind-of-intr", struct xlx_pic, c_kind_of_intr, 0),
89
+static void pxa2xx_draw_line16(void *opaque, uint8_t *dest, const uint8_t *src,
97
+ DEFINE_PROP_UINT32("kind-of-intr", XpsIntc, c_kind_of_intr, 0),
90
+ int width, int deststep)
98
DEFINE_PROP_END_OF_LIST(),
91
{
92
uint32_t data;
93
unsigned int r, g, b;
94
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16(void *opaque,
95
}
96
}
97
98
-static void pxa2xx_draw_line16t(void *opaque,
99
- uint8_t *dest, const uint8_t *src, int width, int deststep)
100
+static void pxa2xx_draw_line16t(void *opaque, uint8_t *dest, const uint8_t *src,
101
+ int width, int deststep)
102
{
103
uint32_t data;
104
unsigned int r, g, b;
105
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line16t(void *opaque,
106
}
107
}
108
109
-static void pxa2xx_draw_line18(void *opaque,
110
- uint8_t *dest, const uint8_t *src, int width, int deststep)
111
+static void pxa2xx_draw_line18(void *opaque, uint8_t *dest, const uint8_t *src,
112
+ int width, int deststep)
113
{
114
uint32_t data;
115
unsigned int r, g, b;
116
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line18(void *opaque,
117
}
118
119
/* The wicked packed format */
120
-static void pxa2xx_draw_line18p(void *opaque,
121
- uint8_t *dest, const uint8_t *src, int width, int deststep)
122
+static void pxa2xx_draw_line18p(void *opaque, uint8_t *dest, const uint8_t *src,
123
+ int width, int deststep)
124
{
125
uint32_t data[3];
126
unsigned int r, g, b;
127
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line18p(void *opaque,
128
}
129
}
130
131
-static void pxa2xx_draw_line19(void *opaque,
132
- uint8_t *dest, const uint8_t *src, int width, int deststep)
133
+static void pxa2xx_draw_line19(void *opaque, uint8_t *dest, const uint8_t *src,
134
+ int width, int deststep)
135
{
136
uint32_t data;
137
unsigned int r, g, b;
138
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19(void *opaque,
139
}
140
141
/* The wicked packed format */
142
-static void pxa2xx_draw_line19p(void *opaque,
143
- uint8_t *dest, const uint8_t *src, int width, int deststep)
144
+static void pxa2xx_draw_line19p(void *opaque, uint8_t *dest, const uint8_t *src,
145
+ int width, int deststep)
146
{
147
uint32_t data[3];
148
unsigned int r, g, b;
149
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line19p(void *opaque,
150
}
151
}
152
153
-static void pxa2xx_draw_line24(void *opaque,
154
- uint8_t *dest, const uint8_t *src, int width, int deststep)
155
+static void pxa2xx_draw_line24(void *opaque, uint8_t *dest, const uint8_t *src,
156
+ int width, int deststep)
157
{
158
uint32_t data;
159
unsigned int r, g, b;
160
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24(void *opaque,
161
}
162
}
163
164
-static void pxa2xx_draw_line24t(void *opaque,
165
- uint8_t *dest, const uint8_t *src, int width, int deststep)
166
+static void pxa2xx_draw_line24t(void *opaque, uint8_t *dest, const uint8_t *src,
167
+ int width, int deststep)
168
{
169
uint32_t data;
170
unsigned int r, g, b;
171
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line24t(void *opaque,
172
}
173
}
174
175
-static void pxa2xx_draw_line25(void *opaque,
176
- uint8_t *dest, const uint8_t *src, int width, int deststep)
177
+static void pxa2xx_draw_line25(void *opaque, uint8_t *dest, const uint8_t *src,
178
+ int width, int deststep)
179
{
180
uint32_t data;
181
unsigned int r, g, b;
182
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_draw_line25(void *opaque,
183
}
184
185
/* Overlay planes disabled, no transparency */
186
-static drawfn pxa2xx_draw_fn_32[16] =
187
-{
188
+static drawfn pxa2xx_draw_fn_32[16] = {
189
[0 ... 0xf] = NULL,
190
[pxa_lcdc_2bpp] = pxa2xx_draw_line2,
191
[pxa_lcdc_4bpp] = pxa2xx_draw_line4,
192
@@ -XXX,XX +XXX,XX @@ static drawfn pxa2xx_draw_fn_32[16] =
193
};
99
};
194
100
195
/* Overlay planes enabled, transparency used */
101
@@ -XXX,XX +XXX,XX @@ static void xilinx_intc_class_init(ObjectClass *klass, void *data)
196
-static drawfn pxa2xx_draw_fn_32t[16] =
102
static const TypeInfo xilinx_intc_info = {
197
-{
103
.name = TYPE_XILINX_INTC,
198
+static drawfn pxa2xx_draw_fn_32t[16] = {
104
.parent = TYPE_SYS_BUS_DEVICE,
199
[0 ... 0xf] = NULL,
105
- .instance_size = sizeof(struct xlx_pic),
200
[pxa_lcdc_4bpp] = pxa2xx_draw_line4,
106
+ .instance_size = sizeof(XpsIntc),
201
[pxa_lcdc_8bpp] = pxa2xx_draw_line8,
107
.instance_init = xilinx_intc_init,
108
.class_init = xilinx_intc_class_init,
109
};
202
--
110
--
203
2.20.1
111
2.34.1
204
112
205
113
diff view generated by jsdifflib
1
From: Richard Henderson <richard.henderson@linaro.org>
1
From: Philippe Mathieu-Daudé <philmd@linaro.org>
2
2
3
Since b64ee454a4a0, all predicate operations should be
3
This remove a use of 'struct' in the DECLARE_INSTANCE_CHECKER()
4
using these field macros for predicates.
4
macro call, to avoid after a QOM refactor:
5
5
6
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
6
hw/timer/xilinx_timer.c:65:1: error: declaration of anonymous struct must be a definition
7
Message-id: 20210309155305.11301-6-richard.henderson@linaro.org
7
DECLARE_INSTANCE_CHECKER(struct timerblock, XILINX_TIMER,
8
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
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-15-philmd@linaro.org
9
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
10
---
15
---
11
target/arm/sve_helper.c | 30 ++++++++++++++----------------
16
hw/timer/xilinx_timer.c | 27 +++++++++++++--------------
12
target/arm/translate-sve.c | 4 ++--
17
1 file changed, 13 insertions(+), 14 deletions(-)
13
2 files changed, 16 insertions(+), 18 deletions(-)
14
18
15
diff --git a/target/arm/sve_helper.c b/target/arm/sve_helper.c
19
diff --git a/hw/timer/xilinx_timer.c b/hw/timer/xilinx_timer.c
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/target/arm/sve_helper.c
21
--- a/hw/timer/xilinx_timer.c
18
+++ b/target/arm/sve_helper.c
22
+++ b/hw/timer/xilinx_timer.c
19
@@ -XXX,XX +XXX,XX @@ static uint32_t do_zero(ARMPredicateReg *d, intptr_t oprsz)
23
@@ -XXX,XX +XXX,XX @@ struct xlx_timer
20
void HELPER(sve_brkpa)(void *vd, void *vn, void *vm, void *vg,
24
};
21
uint32_t pred_desc)
25
26
#define TYPE_XILINX_TIMER "xlnx.xps-timer"
27
-DECLARE_INSTANCE_CHECKER(struct timerblock, XILINX_TIMER,
28
- TYPE_XILINX_TIMER)
29
+typedef struct XpsTimerState XpsTimerState;
30
+DECLARE_INSTANCE_CHECKER(XpsTimerState, XILINX_TIMER, TYPE_XILINX_TIMER)
31
32
-struct timerblock
33
+struct XpsTimerState
22
{
34
{
23
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
35
SysBusDevice parent_obj;
24
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
36
25
if (last_active_pred(vn, vg, oprsz)) {
37
@@ -XXX,XX +XXX,XX @@ struct timerblock
26
compute_brk_z(vd, vm, vg, oprsz, true);
38
struct xlx_timer *timers;
27
} else {
39
};
28
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_brkpa)(void *vd, void *vn, void *vm, void *vg,
40
29
uint32_t HELPER(sve_brkpas)(void *vd, void *vn, void *vm, void *vg,
41
-static inline unsigned int num_timers(struct timerblock *t)
30
uint32_t pred_desc)
42
+static inline unsigned int num_timers(XpsTimerState *t)
31
{
43
{
32
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
44
return 2 - t->one_timer_only;
33
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
45
}
34
if (last_active_pred(vn, vg, oprsz)) {
46
@@ -XXX,XX +XXX,XX @@ static inline unsigned int timer_from_addr(hwaddr addr)
35
return compute_brks_z(vd, vm, vg, oprsz, true);
47
return addr >> 2;
36
} else {
48
}
37
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkpas)(void *vd, void *vn, void *vm, void *vg,
49
38
void HELPER(sve_brkpb)(void *vd, void *vn, void *vm, void *vg,
50
-static void timer_update_irq(struct timerblock *t)
39
uint32_t pred_desc)
51
+static void timer_update_irq(XpsTimerState *t)
40
{
52
{
41
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
53
unsigned int i, irq = 0;
42
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
54
uint32_t csr;
43
if (last_active_pred(vn, vg, oprsz)) {
55
@@ -XXX,XX +XXX,XX @@ static void timer_update_irq(struct timerblock *t)
44
compute_brk_z(vd, vm, vg, oprsz, false);
56
static uint64_t
45
} else {
57
timer_read(void *opaque, hwaddr addr, unsigned int size)
46
@@ -XXX,XX +XXX,XX @@ void HELPER(sve_brkpb)(void *vd, void *vn, void *vm, void *vg,
47
uint32_t HELPER(sve_brkpbs)(void *vd, void *vn, void *vm, void *vg,
48
uint32_t pred_desc)
49
{
58
{
50
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
59
- struct timerblock *t = opaque;
51
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
60
+ XpsTimerState *t = opaque;
52
if (last_active_pred(vn, vg, oprsz)) {
61
struct xlx_timer *xt;
53
return compute_brks_z(vd, vm, vg, oprsz, false);
62
uint32_t r = 0;
54
} else {
63
unsigned int timer;
55
@@ -XXX,XX +XXX,XX @@ uint32_t HELPER(sve_brkpbs)(void *vd, void *vn, void *vm, void *vg,
64
@@ -XXX,XX +XXX,XX @@ static void
56
65
timer_write(void *opaque, hwaddr addr,
57
void HELPER(sve_brka_z)(void *vd, void *vn, void *vg, uint32_t pred_desc)
66
uint64_t val64, unsigned int size)
58
{
67
{
59
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
68
- struct timerblock *t = opaque;
60
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
69
+ XpsTimerState *t = opaque;
61
compute_brk_z(vd, vn, vg, oprsz, true);
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);
62
}
100
}
63
101
64
uint32_t HELPER(sve_brkas_z)(void *vd, void *vn, void *vg, uint32_t pred_desc)
102
static Property xilinx_timer_properties[] = {
65
{
103
- DEFINE_PROP_UINT32("clock-frequency", struct timerblock, freq_hz,
66
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
104
- 62 * 1000000),
67
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
105
- DEFINE_PROP_UINT8("one-timer-only", struct timerblock, one_timer_only, 0),
68
return compute_brks_z(vd, vn, vg, oprsz, true);
106
+ DEFINE_PROP_UINT32("clock-frequency", XpsTimerState, freq_hz, 62 * 1000000),
69
}
107
+ DEFINE_PROP_UINT8("one-timer-only", XpsTimerState, one_timer_only, 0),
70
108
DEFINE_PROP_END_OF_LIST(),
71
void HELPER(sve_brkb_z)(void *vd, void *vn, void *vg, uint32_t pred_desc)
109
};
72
{
110
73
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
111
@@ -XXX,XX +XXX,XX @@ static void xilinx_timer_class_init(ObjectClass *klass, void *data)
74
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
112
static const TypeInfo xilinx_timer_info = {
75
compute_brk_z(vd, vn, vg, oprsz, false);
113
.name = TYPE_XILINX_TIMER,
76
}
114
.parent = TYPE_SYS_BUS_DEVICE,
77
115
- .instance_size = sizeof(struct timerblock),
78
uint32_t HELPER(sve_brkbs_z)(void *vd, void *vn, void *vg, uint32_t pred_desc)
116
+ .instance_size = sizeof(XpsTimerState),
79
{
117
.instance_init = xilinx_timer_init,
80
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
118
.class_init = xilinx_timer_class_init,
81
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
119
};
82
return compute_brks_z(vd, vn, vg, oprsz, false);
83
}
84
85
void HELPER(sve_brka_m)(void *vd, void *vn, void *vg, uint32_t pred_desc)
86
{
87
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
88
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
89
compute_brk_m(vd, vn, vg, oprsz, true);
90
}
91
92
uint32_t HELPER(sve_brkas_m)(void *vd, void *vn, void *vg, uint32_t pred_desc)
93
{
94
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
95
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
96
return compute_brks_m(vd, vn, vg, oprsz, true);
97
}
98
99
void HELPER(sve_brkb_m)(void *vd, void *vn, void *vg, uint32_t pred_desc)
100
{
101
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
102
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
103
compute_brk_m(vd, vn, vg, oprsz, false);
104
}
105
106
uint32_t HELPER(sve_brkbs_m)(void *vd, void *vn, void *vg, uint32_t pred_desc)
107
{
108
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
109
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
110
return compute_brks_m(vd, vn, vg, oprsz, false);
111
}
112
113
void HELPER(sve_brkn)(void *vd, void *vn, void *vg, uint32_t pred_desc)
114
{
115
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
116
-
117
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
118
if (!last_active_pred(vn, vg, oprsz)) {
119
do_zero(vd, oprsz);
120
}
121
@@ -XXX,XX +XXX,XX @@ static uint32_t predtest_ones(ARMPredicateReg *d, intptr_t oprsz,
122
123
uint32_t HELPER(sve_brkns)(void *vd, void *vn, void *vg, uint32_t pred_desc)
124
{
125
- intptr_t oprsz = extract32(pred_desc, 0, SIMD_OPRSZ_BITS) + 2;
126
-
127
+ intptr_t oprsz = FIELD_EX32(pred_desc, PREDDESC, OPRSZ);
128
if (last_active_pred(vn, vg, oprsz)) {
129
return predtest_ones(vd, oprsz, -1);
130
} else {
131
diff --git a/target/arm/translate-sve.c b/target/arm/translate-sve.c
132
index XXXXXXX..XXXXXXX 100644
133
--- a/target/arm/translate-sve.c
134
+++ b/target/arm/translate-sve.c
135
@@ -XXX,XX +XXX,XX @@ static bool do_brk3(DisasContext *s, arg_rprr_s *a,
136
TCGv_ptr n = tcg_temp_new_ptr();
137
TCGv_ptr m = tcg_temp_new_ptr();
138
TCGv_ptr g = tcg_temp_new_ptr();
139
- TCGv_i32 t = tcg_const_i32(vsz - 2);
140
+ TCGv_i32 t = tcg_const_i32(FIELD_DP32(0, PREDDESC, OPRSZ, vsz));
141
142
tcg_gen_addi_ptr(d, cpu_env, pred_full_reg_offset(s, a->rd));
143
tcg_gen_addi_ptr(n, cpu_env, pred_full_reg_offset(s, a->rn));
144
@@ -XXX,XX +XXX,XX @@ static bool do_brk2(DisasContext *s, arg_rpr_s *a,
145
TCGv_ptr d = tcg_temp_new_ptr();
146
TCGv_ptr n = tcg_temp_new_ptr();
147
TCGv_ptr g = tcg_temp_new_ptr();
148
- TCGv_i32 t = tcg_const_i32(vsz - 2);
149
+ TCGv_i32 t = tcg_const_i32(FIELD_DP32(0, PREDDESC, OPRSZ, vsz));
150
151
tcg_gen_addi_ptr(d, cpu_env, pred_full_reg_offset(s, a->rd));
152
tcg_gen_addi_ptr(n, cpu_env, pred_full_reg_offset(s, a->rn));
153
--
120
--
154
2.20.1
121
2.34.1
155
122
156
123
diff view generated by jsdifflib
1
From: Eric Auger <eric.auger@redhat.com>
1
From: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
2
2
3
If the asid is not set, do not attempt to locate the key directly
3
ARM trusted firmware, when built with FEAT_HCX support, sets SCR_EL3.HXEn bit
4
as all inserted keys have a valid asid.
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
Use g_hash_table_foreach_remove instead.
10
Cc: qemu-stable@nongnu.org
7
11
Signed-off-by: Evgeny Iakovlev <eiakovlev@linux.microsoft.com>
8
Signed-off-by: Eric Auger <eric.auger@redhat.com>
12
Message-id: 20230105221251.17896-4-eiakovlev@linux.microsoft.com
9
Message-id: 20210309102742.30442-5-eric.auger@redhat.com
10
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
11
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
14
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
12
---
15
---
13
hw/arm/smmu-common.c | 2 +-
16
target/arm/helper.c | 3 +++
14
1 file changed, 1 insertion(+), 1 deletion(-)
17
1 file changed, 3 insertions(+)
15
18
16
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
19
diff --git a/target/arm/helper.c b/target/arm/helper.c
17
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
18
--- a/hw/arm/smmu-common.c
21
--- a/target/arm/helper.c
19
+++ b/hw/arm/smmu-common.c
22
+++ b/target/arm/helper.c
20
@@ -XXX,XX +XXX,XX @@ inline void
23
@@ -XXX,XX +XXX,XX @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
21
smmu_iotlb_inv_iova(SMMUState *s, int asid, dma_addr_t iova,
24
if (cpu_isar_feature(aa64_sme, cpu)) {
22
uint8_t tg, uint64_t num_pages, uint8_t ttl)
25
valid_mask |= SCR_ENTP2;
23
{
26
}
24
- if (ttl && (num_pages == 1)) {
27
+ if (cpu_isar_feature(aa64_hcx, cpu)) {
25
+ if (ttl && (num_pages == 1) && (asid >= 0)) {
28
+ valid_mask |= SCR_HXEN;
26
SMMUIOTLBKey key = smmu_get_iotlb_key(asid, iova, tg, ttl);
29
+ }
27
30
} else {
28
g_hash_table_remove(s->iotlb, &key);
31
valid_mask &= ~(SCR_RW | SCR_ST);
32
if (cpu_isar_feature(aa32_ras, cpu)) {
29
--
33
--
30
2.20.1
34
2.34.1
31
32
diff view generated by jsdifflib
Deleted patch
1
Since the dest_width is now always 4 because the output surface is
2
32bpp, we can replace the dest_width state field with a constant.
3
1
4
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
5
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
6
Message-id: 20210211141515.8755-6-peter.maydell@linaro.org
7
---
8
hw/display/pxa2xx_lcd.c | 20 +++++++++++---------
9
1 file changed, 11 insertions(+), 9 deletions(-)
10
11
diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/hw/display/pxa2xx_lcd.c
14
+++ b/hw/display/pxa2xx_lcd.c
15
@@ -XXX,XX +XXX,XX @@ typedef struct QEMU_PACKED {
16
#define LDCMD_SOFINT    (1 << 22)
17
#define LDCMD_PAL    (1 << 26)
18
19
+/* Size of a pixel in the QEMU UI output surface, in bytes */
20
+#define DEST_PIXEL_WIDTH 4
21
+
22
#define BITS 32
23
#include "pxa2xx_template.h"
24
25
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot0(PXA2xxLCDState *s,
26
else if (s->bpp > pxa_lcdc_8bpp)
27
src_width *= 2;
28
29
- dest_width = s->xres * s->dest_width;
30
+ dest_width = s->xres * DEST_PIXEL_WIDTH;
31
*miny = 0;
32
if (s->invalidated) {
33
framebuffer_update_memory_section(&s->fbsection, s->sysmem,
34
addr, s->yres, src_width);
35
}
36
framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres,
37
- src_width, dest_width, s->dest_width,
38
+ src_width, dest_width, DEST_PIXEL_WIDTH,
39
s->invalidated,
40
fn, s->dma_ch[0].palette, miny, maxy);
41
}
42
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot90(PXA2xxLCDState *s,
43
else if (s->bpp > pxa_lcdc_8bpp)
44
src_width *= 2;
45
46
- dest_width = s->yres * s->dest_width;
47
+ dest_width = s->yres * DEST_PIXEL_WIDTH;
48
*miny = 0;
49
if (s->invalidated) {
50
framebuffer_update_memory_section(&s->fbsection, s->sysmem,
51
addr, s->yres, src_width);
52
}
53
framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres,
54
- src_width, s->dest_width, -dest_width,
55
+ src_width, DEST_PIXEL_WIDTH, -dest_width,
56
s->invalidated,
57
fn, s->dma_ch[0].palette,
58
miny, maxy);
59
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot180(PXA2xxLCDState *s,
60
src_width *= 2;
61
}
62
63
- dest_width = s->xres * s->dest_width;
64
+ dest_width = s->xres * DEST_PIXEL_WIDTH;
65
*miny = 0;
66
if (s->invalidated) {
67
framebuffer_update_memory_section(&s->fbsection, s->sysmem,
68
addr, s->yres, src_width);
69
}
70
framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres,
71
- src_width, -dest_width, -s->dest_width,
72
+ src_width, -dest_width, -DEST_PIXEL_WIDTH,
73
s->invalidated,
74
fn, s->dma_ch[0].palette, miny, maxy);
75
}
76
@@ -XXX,XX +XXX,XX @@ static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s,
77
src_width *= 2;
78
}
79
80
- dest_width = s->yres * s->dest_width;
81
+ dest_width = s->yres * DEST_PIXEL_WIDTH;
82
*miny = 0;
83
if (s->invalidated) {
84
framebuffer_update_memory_section(&s->fbsection, s->sysmem,
85
addr, s->yres, src_width);
86
}
87
framebuffer_update_display(surface, &s->fbsection, s->xres, s->yres,
88
- src_width, -s->dest_width, dest_width,
89
+ src_width, -DEST_PIXEL_WIDTH, dest_width,
90
s->invalidated,
91
fn, s->dma_ch[0].palette,
92
miny, maxy);
93
@@ -XXX,XX +XXX,XX @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
94
memory_region_add_subregion(sysmem, base, &s->iomem);
95
96
s->con = graphic_console_init(NULL, 0, &pxa2xx_ops, s);
97
- s->dest_width = 4;
98
99
vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s);
100
101
--
102
2.20.1
103
104
diff view generated by jsdifflib