*** Add allwinner-r40 support ***
Subsystems (3)
v5 cover *** Add allwinner-r40 support ***
From: qianfan Zhao <[email protected]>
***History***
# v1: 2023-03-21
The first version which add allwinner-r40 support, supported features:
+ ccu
+ dram controller
+ uart
+ i2c and pmic(axp221)
+ sdcard
+ emac/gmac
Also provide a test case under avocado, running quickly test:
$ AVOCADO_ALLOW_LARGE_STORAGE=yes tests/venv/bin/avocado \
--verbose --show=app,console run -t machine:bpim2u \
../tests/avocado/boot_linux_console.py# v2: 2023-03-28
1. Fix the waring and error reported by checkpatch.pl
2. Remove the other i2c controllers except that i2c0
3. Use an array to register mmc and uart devices
4. Rename axp209 to axp22x and add axp221 support
5. Add a basic SRAM controller
# v3: 2023-04-18
1. Update some commit messages
2. Squash those two commit about sdcard
hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
hw: arm: allwinner-r40: Fix the mmc controller's type
# v4: 2023-05-10
1. Rebase to master
# v5: 2023-05-23
1. Rebase to master
2. Update based on Niek Linnenbank's guide.
qianfan Zhao (11):
hw: arm: Add bananapi M2-Ultra and allwinner-r40 support hw/arm/allwinner-r40: add Clock Control Unit
hw: allwinner-r40: Complete uart devices
hw: arm: allwinner-r40: Add i2c0 device
hw/misc: Rename axp209 to axp22x and add support AXP221 PMU hw/arm/allwinner-r40: add SDRAM controller device
hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
hw: arm: allwinner-r40: Add emac and gmac support
hw: arm: allwinner-sramc: Add SRAM Controller support for R40
tests: avocado: boot_linux_console: Add test case for bpim2u
docs: system: arm: Introduce bananapi_m2u
docs/system/arm/bananapi_m2u.rst | 138 +++++++ hw/arm/Kconfig | 14 +- hw/arm/allwinner-r40.c | 526 ++++++++++++++++++++++++++ hw/arm/bananapi_m2u.c | 145 +++++++ hw/arm/meson.build | 1 + hw/misc/Kconfig | 5 +- hw/misc/allwinner-r40-ccu.c | 209 ++++++++++ hw/misc/allwinner-r40-dramc.c | 513 +++++++++++++++++++++++++ hw/misc/allwinner-sramc.c | 184 +++++++++ hw/misc/axp209.c | 238 ------------ hw/misc/axp2xx.c | 283 ++++++++++++++ hw/misc/meson.build | 5 +- hw/misc/trace-events | 26 +- hw/sd/allwinner-sdhost.c | 72 +++- include/hw/arm/allwinner-r40.h | 143 +++++++ include/hw/misc/allwinner-r40-ccu.h | 65 ++++ include/hw/misc/allwinner-r40-dramc.h | 108 ++++++ include/hw/misc/allwinner-sramc.h | 69 ++++ include/hw/sd/allwinner-sdhost.h | 9 + tests/avocado/boot_linux_console.py | 176 +++++++++ 20 files changed, 2681 insertions(+), 248 deletions(-) create mode 100644 docs/system/arm/bananapi_m2u.rst create mode 100644 hw/arm/allwinner-r40.c create mode 100644 hw/arm/bananapi_m2u.c create mode 100644 hw/misc/allwinner-r40-ccu.c create mode 100644 hw/misc/allwinner-r40-dramc.c create mode 100644 hw/misc/allwinner-sramc.c delete mode 100644 hw/misc/axp209.c create mode 100644 hw/misc/axp2xx.c create mode 100644 include/hw/arm/allwinner-r40.h create mode 100644 include/hw/misc/allwinner-r40-ccu.h create mode 100644 include/hw/misc/allwinner-r40-dramc.h create mode 100644 include/hw/misc/allwinner-sramc.h
Signature · 1 line
2.25.1
PATCH v5 1/11 hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
--- hw/arm/Kconfig | 10 + hw/arm/allwinner-r40.c | 415 +++++++++++++++++++++++++++++++++ hw/arm/bananapi_m2u.c | 129 ++++++++++ hw/arm/meson.build | 1 + include/hw/arm/allwinner-r40.h | 110 +++++++++ 5 files changed, 665 insertions(+) create mode 100644 hw/arm/allwinner-r40.c create mode 100644 hw/arm/bananapi_m2u.c create mode 100644 include/hw/arm/allwinner-r40.h
hw/arm/Kconfig +10 -0
@@ -374,6 +374,16 @@ config ALLWINNER_H3 select USB_EHCI_SYSBUS select SD +config ALLWINNER_R40 + bool + default y if TCG && ARM + select ALLWINNER_A10_PIT + select SERIAL + select ARM_TIMER + select ARM_GIC + select UNIMP + select SD + config RASPI bool default y if TCG && ARM
hw/arm/allwinner-r40.c new file +415 -0
415 lines not on this page · raw message
hw/arm/bananapi_m2u.c new file +129 -0
129 lines not on this page · raw message
hw/arm/meson.build +1 -0
@@ -37,6 +37,7 @@ arm_ss.add(when: 'CONFIG_OMAP', if_true: files('omap1.c', 'omap2.c')) arm_ss.add(when: 'CONFIG_STRONGARM', if_true: files('strongarm.c')) arm_ss.add(when: 'CONFIG_ALLWINNER_A10', if_true: files('allwinner-a10.c', 'cubieboard.c')) arm_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3.c', 'orangepi.c')) +arm_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40.c', 'bananapi_m2u.c')) arm_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2836.c', 'raspi.c')) arm_ss.add(when: 'CONFIG_STM32F100_SOC', if_true: files('stm32f100_soc.c')) arm_ss.add(when: 'CONFIG_STM32F205_SOC', if_true: files('stm32f205_soc.c'))
include/hw/arm/allwinner-r40.h new file +110 -0
110 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Hi,
Quoted 9 lines · On Tue, May 23, 2023 at 06:04:58PM +0800, [email protected] wrote:
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
Signed-off-by qianfan Zhao <[email protected]>Reviewed-by Niek Linnenbank <[email protected]>
I tried this in mainline linux with the following command.
qemu-system-arm -M bpim2u \ -kernel arch/arm/boot/zImage -no-reboot \ -snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \ -nic user \ --append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \ -dtb arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb \ -nographic -monitor null -serial stdio
Main problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
mmc0: Failed to initialize a non-removable card
Using "-sd <file>" instead of "-drive file=<file>" does not make a difference.
I can fix (work around ?) the problem by adding the following information to the devicetree file.
aliases {
ethernet0 = &gmac;
serial0 = &uart0;
+ mmc0 = &mmc0;
+ mmc1 = &mmc1;
+ mmc2 = &mmc2;
};Linux upstream commits fa2d0aa96941 and 2a43322ca7f3 describe the logic behind this change.
Is this a bug in the Linux kernel, or a problem with the qemu emulation ? Either case, is there a way to specify a qemu command line that doesn't result in random assignments of the provided drive to mmc0/1/2 ?
Thanks,
Guenter
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Quoted 43 lines · Guenter Roeck
Hi,
Quoted 9 lines · On Tue, May 23, 2023 at 06:04:58PM +0800, [email protected] wrote:
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
Signed-off-by qianfan Zhao <[email protected]>Reviewed-by Niek Linnenbank <[email protected]>I tried this in mainline linux with the following command.
qemu-system-arm -M bpim2u \ -kernel arch/arm/boot/zImage -no-reboot \ -snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \ -nic user \ --append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \ -dtb arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb \ -nographic -monitor null -serial stdioMain problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
mmc0: Failed to initialize a non-removable card
Using "-sd <file>" instead of "-drive file=<file>" does not make a difference.
I can fix (work around ?) the problem by adding the following information to the devicetree file.
aliases { ethernet0 = &gmac; serial0 = &uart0;(quoted diff) +3
-0+ mmc0 = &mmc0; + mmc1 = &mmc1; + mmc2 = &mmc2; };
Quoted 4 lines
Linux upstream commits
fa2d0aa96941and2a43322ca7f3describe the logic behind this change.Is this a bug in the Linux kernel, or a problem with the qemu emulation ?
On my work, the linux kenrel doesn't startup ext4 rootfs directly, it start
a custom ramdisk and we can handle this in ramdisk scripts.
Quoted 5 lines
Either case, is there a way to specify a qemu command line that doesn't result in random assignments of the provided drive to mmc0/1/2 ?
Thanks,
Guenter
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Quoted 45 lines · qianfan
Quoted 43 lines · Guenter Roeck
Hi,
Quoted 9 lines · On Tue, May 23, 2023 at 06:04:58PM +0800, [email protected] wrote:
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
Signed-off-by qianfan Zhao <[email protected]>Reviewed-by Niek Linnenbank <[email protected]>I tried this in mainline linux with the following command.
qemu-system-arm -M bpim2u \ -kernel arch/arm/boot/zImage -no-reboot \ -snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \ -nic user \ --append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \ -dtb arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb \ -nographic -monitor null -serial stdioMain problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
mmc0: Failed to initialize a non-removable card
Using "-sd <file>" instead of "-drive file=<file>" does not make a difference.
I can fix (work around ?) the problem by adding the following information to the devicetree file.
aliases { ethernet0 = &gmac; serial0 = &uart0;(quoted diff) +3
-0+ mmc0 = &mmc0; + mmc1 = &mmc1; + mmc2 = &mmc2; };
Quoted 9 lines
Quoted 4 lines
Linux upstream commits
fa2d0aa96941and2a43322ca7f3describe the logic behind this change.Is this a bug in the Linux kernel, or a problem with the qemu emulation ?
On my work, the linux kenrel doesn't startup ext4 rootfs directly, it start
a custom ramdisk and we can handle this in ramdisk scripts.
That won't help for automated testing.
I guess that means the answer to my question below is "no".
Thanks,
Guenter
Quoted 6 lines
Quoted 5 lines
Either case, is there a way to specify a qemu command line that doesn't result in random assignments of the provided drive to mmc0/1/2 ?
Thanks,
Guenter
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
In reply to Guenter RoeckQuoted 24 lines · Guenter Roeck
Hi,
Quoted 9 lines · On Tue, May 23, 2023 at 06:04:58PM +0800, [email protected] wrote:
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
Signed-off-by qianfan Zhao <[email protected]>Reviewed-by Niek Linnenbank <[email protected]>I tried this in mainline linux with the following command.
qemu-system-arm -M bpim2u \ -kernel arch/arm/boot/zImage -no-reboot \ -snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \ -nic user \ --append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \ -dtb arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb \ -nographic -monitor null -serial stdio
Quoted 6 lines
Main problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
mmc0: Failed to initialize a non-removable card
Do you mean that QEMU randomly connects the SD card to a different MMC controller each time, or that Linux is randomly assigning mmc0 to a different MMC controller each time ?
thanks
-- PMM
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Quoted 30 lines · Peter Maydell
Quoted 29 lines · Guenter Roeck
Hi,
Quoted 9 lines · On Tue, May 23, 2023 at 06:04:58PM +0800, [email protected] wrote:
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
Signed-off-by qianfan Zhao <[email protected]>Reviewed-by Niek Linnenbank <[email protected]>I tried this in mainline linux with the following command.
qemu-system-arm -M bpim2u \ -kernel arch/arm/boot/zImage -no-reboot \ -snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \ -nic user \ --append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \ -dtb arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb \ -nographic -monitor null -serial stdioMain problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
Quoted 7 lines
Quoted 1 line
mmc0: Failed to initialize a non-removable card
Do you mean that QEMU randomly connects the SD card to a different MMC controller each time, or that Linux is randomly assigning mmc0 to a different MMC controller each time ?
Good question. Given the workaround (fix ?) I suggested is in the devicetree file, I would assume it is the latter. I suspect that Linux assigns drive names based on hardware detection order, and that this is not deterministic for some reason. It is odd because I have never experienced that with any other emulation.
A secondary problem may be that Linux thinks that the first drive is not removable, even though it is a SD drive. I think that is a problem with qemu, but I don't understand the qemu code well enough to understand why. It seems that the mmc capability register always has bit 8 set, even for the first drive, but I don't know where/how that is set and how to change it. SDHCI has the capareg property, but that isn't used here (or I don't know how to use/set it).
Guenter
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Quoted 40 lines · Guenter Roeck
Quoted 30 lines · Peter Maydell
Quoted 29 lines · Guenter Roeck
Hi,
Quoted 9 lines · On Tue, May 23, 2023 at 06:04:58PM +0800, [email protected] wrote:
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
Signed-off-by qianfan Zhao <[email protected]>Reviewed-by Niek Linnenbank <[email protected]>I tried this in mainline linux with the following command.
qemu-system-arm -M bpim2u \ -kernel arch/arm/boot/zImage -no-reboot \ -snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \ -nic user \ --append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \ -dtb arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb \ -nographic -monitor null -serial stdioMain problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
Quoted 7 lines
Quoted 1 line
mmc0: Failed to initialize a non-removable card
Do you mean that QEMU randomly connects the SD card to a different MMC controller each time, or that Linux is randomly assigning mmc0 to a different MMC controller each time ?
Quoted 5 lines
Good question. Given the workaround (fix ?) I suggested is in the devicetree file, I would assume it is the latter. I suspect that Linux assigns drive names based on hardware detection order, and that this is not deterministic for some reason. It is odd because I have never experienced that with any other emulation.
Yeah, I don't really understand why it would be non-deterministic. But it does make it sound like the right thing is for the device tree file to explicitly say which MMC controller is which -- presumably you might get unlucky with the timing on real hardware too.
Quoted 8 lines
A secondary problem may be that Linux thinks that the first drive is not removable, even though it is a SD drive. I think that is a problem with qemu, but I don't understand the qemu code well enough to understand why. It seems that the mmc capability register always has bit 8 set, even for the first drive, but I don't know where/how that is set and how to change it. SDHCI has the capareg property, but that isn't used here (or I don't know how to use/set it).
Yeah, this seems likely to be something we're getting wrong. I assume on other QEMU boards the SD card appears as removeable ?
thanks
-- PMM
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Quoted 47 lines · Peter Maydell
Quoted 40 lines · Guenter Roeck
Quoted 30 lines · Peter Maydell
Quoted 29 lines · Guenter Roeck
Hi,
Quoted 9 lines · On Tue, May 23, 2023 at 06:04:58PM +0800, [email protected] wrote:
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
Signed-off-by qianfan Zhao <[email protected]>Reviewed-by Niek Linnenbank <[email protected]>I tried this in mainline linux with the following command.
qemu-system-arm -M bpim2u \ -kernel arch/arm/boot/zImage -no-reboot \ -snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \ -nic user \ --append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \ -dtb arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb \ -nographic -monitor null -serial stdioMain problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
Quoted 7 lines
Quoted 1 line
mmc0: Failed to initialize a non-removable card
Do you mean that QEMU randomly connects the SD card to a different MMC controller each time, or that Linux is randomly assigning mmc0 to a different MMC controller each time ?
Quoted 5 lines
Good question. Given the workaround (fix ?) I suggested is in the devicetree file, I would assume it is the latter. I suspect that Linux assigns drive names based on hardware detection order, and that this is not deterministic for some reason. It is odd because I have never experienced that with any other emulation.
Quoted 6 lines
Yeah, I don't really understand why it would be non-deterministic. But it does make it sound like the right thing is for the device tree file to explicitly say which MMC controller is which -- presumably you might get unlucky with the timing on real hardware too.
Agreed, only someone with real hardware would have to confirm that this is the case.
Quoted 9 lines
Quoted 8 lines
A secondary problem may be that Linux thinks that the first drive is not removable, even though it is a SD drive. I think that is a problem with qemu, but I don't understand the qemu code well enough to understand why. It seems that the mmc capability register always has bit 8 set, even for the first drive, but I don't know where/how that is set and how to change it. SDHCI has the capareg property, but that isn't used here (or I don't know how to use/set it).
Quoted 4 lines
Yeah, this seems likely to be something we're getting wrong. I assume on other QEMU boards the SD card appears as removeable ?
Yes. With some added debugging, sabrelite, and no drive provided in the qemu command:
mmc0: SDHCI controller on 2198000.mmc [2198000.mmc] using ADMA ############# mmc0: No card inserted, removable=1
mmc1: SDHCI controller on 219c000.mmc [219c000.mmc] using ADMA ############# mmc1: No card inserted, removable=1
Thanks,
Guenter
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Quoted 55 lines · Guenter Roeck
Quoted 47 lines · Peter Maydell
Quoted 40 lines · Guenter Roeck
Quoted 30 lines · Peter Maydell
Quoted 29 lines · Guenter Roeck
Hi,
Quoted 9 lines · On Tue, May 23, 2023 at 06:04:58PM +0800, [email protected] wrote:
From: qianfan Zhao <[email protected]>
Allwinner R40 (sun8i) SoC features a Quad-Core Cortex-A7 ARM CPU, and a Mali400 MP2 GPU from ARM. It's also known as the Allwinner T3 for In-Car Entertainment usage, A40i and A40pro are variants that differ in applicable temperatures range (industrial and military).
Signed-off-by qianfan Zhao <[email protected]>Reviewed-by Niek Linnenbank <[email protected]>I tried this in mainline linux with the following command.
qemu-system-arm -M bpim2u \
-kernelarch/arm/boot/zImage-no-reboot \
-snapshot -drive file=rootfs-armv7a.ext2,format=raw,if=sd \
-nic user \
--append "root=/dev/mmcblk0 rootwait console=ttyS0,115200" \
-dtbarch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dtb\
-nographic -monitor null -serial stdioMain problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
Quoted 7 lines
Quoted 1 line
mmc0: Failed to initialize a non-removable card
Do you mean that QEMU randomly connects the SD card to a different MMC controller each time, or that Linux is randomly assigning mmc0 to a different MMC controller each time ?
Quoted 5 lines
Good question. Given the workaround (fix ?) I suggested is in the devicetree file, I would assume it is the latter. I suspect that Linux assigns drive names based on hardware detection order, and that this is not deterministic for some reason. It is odd because I have never experienced that with any other emulation.
Quoted 6 lines
Yeah, I don't really understand why it would be non-deterministic. But it does make it sound like the right thing is for the device tree file to explicitly say which MMC controller is which -- presumably you might get unlucky with the timing on real hardware too.
Quoted 3 lines
Agreed, only someone with real hardware would have to confirm that this is the case.
Actually, the reason is quite simple. In the Linux kernel:
static struct platform_driver sunxi_mmc_driver = {
.driver = {
.name = "sunxi-mmc",
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
^^^^^^^^^^^^^^^^^^^^^^^^^
.of_match_table = sunxi_mmc_of_match,
.pm = &sunxi_mmc_pm_ops,
},
.probe = sunxi_mmc_probe,
.remove = sunxi_mmc_remove,
};All mmc devices instantiate at the same time, thus the device name association is random. If I drop the probe_type assignment, it becomes deterministic.
On top of that, Linux does know which drives are removable from the devicetree file. However, since probe order is random, the assignment of the one removable drive to device names is random. Sometimes mmc0 shows up as removable, sometimes it is mmc1 or mmc2.
So my conclusion is that qemu isn't doing anything wrong, it is all happening in the Linux kernel.
Thanks, and sorry for the noise.
Guenter
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Quoted 55 lines · Guenter Roeck
Quoted 31 lines · Guenter Roeck
Quoted 23 lines · Peter Maydell
Quoted 16 lines · Guenter Roeck
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Guenter Roeck
Main problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
Quoted 7 lines
Quoted 1 line
mmc0: Failed to initialize a non-removable card
Do you mean that QEMU randomly connects the SD card to a different MMC controller each time, or that Linux is randomly assigning mmc0 to a different MMC controller each time ?
Quoted 5 lines
Good question. Given the workaround (fix ?) I suggested is in the devicetree file, I would assume it is the latter. I suspect that Linux assigns drive names based on hardware detection order, and that this is not deterministic for some reason. It is odd because I have never experienced that with any other emulation.
Quoted 6 lines
Yeah, I don't really understand why it would be non-deterministic. But it does make it sound like the right thing is for the device tree file to explicitly say which MMC controller is which -- presumably you might get unlucky with the timing on real hardware too.
Quoted 3 lines
Agreed, only someone with real hardware would have to confirm that this is the case.
Actually, the reason is quite simple. In the Linux kernel:
static struct platform_driver sunxi_mmc_driver = { .driver = { .name = "sunxi-mmc", .probe_type = PROBE_PREFER_ASYNCHRONOUS, ^^^^^^^^^^^^^^^^^^^^^^^^^ .of_match_table = sunxi_mmc_of_match, .pm = &sunxi_mmc_pm_ops, }, .probe = sunxi_mmc_probe, .remove = sunxi_mmc_remove, };All mmc devices instantiate at the same time, thus the device name association is random. If I drop the
probe_typeassignment, it becomes deterministic.
Quoted 8 lines
On top of that, Linux does know which drives are removable from the devicetree file. However, since probe order is random, the assignment of the one removable drive to device names is random. Sometimes mmc0 shows up as removable, sometimes it is mmc1 or mmc2.
So my conclusion is that qemu isn't doing anything wrong, it is all happening in the Linux kernel.
Hi Guenter -- do you know if this "random MMC controller" issue has been fixed in Linux ? If so, we might be able to update our test case image to avoid the slightly ugly "root=b300" workaround at some point.
thanks
-- PMM
Re: [PATCH v5 01/11] hw: arm: Add bananapi M2-Ultra and allwinner-r40 support
Quoted 62 lines · Peter Maydell
Quoted 61 lines · Guenter Roeck
Quoted 31 lines · Guenter Roeck
Quoted 23 lines · Peter Maydell
Quoted 16 lines · Guenter Roeck
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Guenter Roeck
Main problem is that the SD card gets instantiated randomly to mmc0, mmc1, or mmc2, making it all but impossible to specify a root file system device. The non-instantiated cards are always reported as non-removable, including mmc0. Example:
Quoted 7 lines
Quoted 1 line
mmc0: Failed to initialize a non-removable card
Do you mean that QEMU randomly connects the SD card to a different MMC controller each time, or that Linux is randomly assigning mmc0 to a different MMC controller each time ?
Quoted 5 lines
Good question. Given the workaround (fix ?) I suggested is in the devicetree file, I would assume it is the latter. I suspect that Linux assigns drive names based on hardware detection order, and that this is not deterministic for some reason. It is odd because I have never experienced that with any other emulation.
Quoted 6 lines
Yeah, I don't really understand why it would be non-deterministic. But it does make it sound like the right thing is for the device tree file to explicitly say which MMC controller is which -- presumably you might get unlucky with the timing on real hardware too.
Quoted 3 lines
Agreed, only someone with real hardware would have to confirm that this is the case.
Actually, the reason is quite simple. In the Linux kernel:
static struct platform_driver sunxi_mmc_driver = { .driver = { .name = "sunxi-mmc", .probe_type = PROBE_PREFER_ASYNCHRONOUS, ^^^^^^^^^^^^^^^^^^^^^^^^^ .of_match_table = sunxi_mmc_of_match, .pm = &sunxi_mmc_pm_ops, }, .probe = sunxi_mmc_probe, .remove = sunxi_mmc_remove, };All mmc devices instantiate at the same time, thus the device name association is random. If I drop the
probe_typeassignment, it becomes deterministic.On top of that, Linux does know which drives are removable from the devicetree file. However, since probe order is random, the assignment of the one removable drive to device names is random. Sometimes mmc0 shows up as removable, sometimes it is mmc1 or mmc2.
Quoted 8 lines
Quoted 2 lines
So my conclusion is that qemu isn't doing anything wrong, it is all happening in the Linux kernel.
Hi Guenter -- do you know if this "random MMC controller" issue has been fixed in Linux ? If so, we might be able to update our test case image to avoid the slightly ugly "root=b300" workaround at some point.
No, it has not been fixed, or at least there is nothing in linux-next. I don't have real hardware, so I am not in a position to submit, much less test, a patch on it. Someone had mentioned that real hardware would handle the problem in initramfs. That seems wrong to me, but it is what it is.
I changed my own test to use the "root=b300" hack. That seems highly kludgy, but at least it works.
Guenter
PATCH v5 2/11 hw/arm/allwinner-r40: add Clock Control Unit
In reply to [email protected]From: qianfan Zhao <[email protected]>
The CCU provides the registers to program the PLLs and the controls most of the clock generation, division, distribution, synchronization and gating.
This commit adds support for the Clock Control Unit which emulates a simple read/write register interface.
--- hw/arm/allwinner-r40.c | 8 +- hw/misc/allwinner-r40-ccu.c | 209 ++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + include/hw/arm/allwinner-r40.h | 2 + include/hw/misc/allwinner-r40-ccu.h | 65 +++++++++ 5 files changed, 284 insertions(+), 1 deletion(-) create mode 100644 hw/misc/allwinner-r40-ccu.c create mode 100644 include/hw/misc/allwinner-r40-ccu.h
hw/arm/allwinner-r40.c +7 -1
@@ -42,6 +42,7 @@ const hwaddr allwinner_r40_memmap[] = { [AW_R40_DEV_MMC1] = 0x01c10000, [AW_R40_DEV_MMC2] = 0x01c11000, [AW_R40_DEV_MMC3] = 0x01c12000, + [AW_R40_DEV_CCU] = 0x01c20000, [AW_R40_DEV_PIT] = 0x01c20c00, [AW_R40_DEV_UART0] = 0x01c28000, [AW_R40_DEV_GIC_DIST] = 0x01c81000,
@@ -80,7 +81,6 @@ static struct AwR40Unimplemented r40_unimplemented[] = { { "usb2-host", 0x01c1c000, 4 * KiB }, { "cs1", 0x01c1d000, 4 * KiB }, { "spi3", 0x01c1f000, 4 * KiB }, - { "ccu", 0x01c20000, 1 * KiB }, { "rtc", 0x01c20400, 1 * KiB }, { "pio", 0x01c20800, 1 * KiB }, { "owa", 0x01c21000, 1 * KiB },
@@ -250,6 +250,8 @@ static void allwinner_r40_init(Object *obj)object_property_add_alias (obj,"clk1-freq" ,OBJECT (&s->timer),"clk1-freq" ); +object_initialize_child (obj,"ccu" , &s->ccu,TYPE_AW_R40_CCU ); +for (int i =0 ; i <AW_R40_NUM_MMCS ; i++) {object_initialize_child (obj, mmc_names[i], &s->mmc[i],TYPE_AW_SDHOST_SUN5I );
@@ -364,6 +366,10 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp)memory_region_add_subregion (get_system_memory (), s->memmap[AW_R40_DEV_SRAM_A4 ], &s->sram_a4); +/* Clock Control Unit */ +sysbus_realize (SYS_BUS_DEVICE (&s->ccu), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->ccu),0 , s->memmap[AW_R40_DEV_CCU ]); +/* SD/MMC */ for (int i =0 ; i <AW_R40_NUM_MMCS ; i++) { qemu_irq irq = qdev_get_gpio_in(DEVICE(&s->gic),
hw/misc/allwinner-r40-ccu.c new file +209 -0
209 lines not on this page · raw message
hw/misc/meson.build +1 -0
@@ -44,6 +44,7 @@ specific_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-cpucfg.c' softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-sysctrl.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sid.c')) +softmmu_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40-ccu.c')) softmmu_ss.add(when: 'CONFIG_AXP209_PMU', if_true: files('axp209.c')) softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('arm_sysctl.c')) softmmu_ss.add(when: 'CONFIG_NSERIES', if_true: files('cbus.c'))
include/hw/arm/allwinner-r40.h +2 -0
@@ -25,6 +25,7 @@#include "hw/timer/allwinner-a10-pit.h" #include "hw/intc/arm_gic.h" #include "hw/sd/allwinner-sdhost.h" +#include "hw/misc/allwinner-r40-ccu.h" #include "target/arm/cpu.h" #include "sysemu/block-backend.h"
@@ -79,6 +80,7 @@ struct AwR40State {const hwaddr *memmap;AwA10PITState timer;AwSdHostState mmc[AW_R40_NUM_MMCS ]; +AwR40ClockCtlState ccu;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
include/hw/misc/allwinner-r40-ccu.h new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 3/11 hw: allwinner-r40: Complete uart devices
In reply to [email protected]From: qianfan Zhao <[email protected]>
R40 has eight UARTs, support both 16450 and 16550 compatible modes.
--- hw/arm/allwinner-r40.c | 34 +++++++++++++++++++++++++++++++--- include/hw/arm/allwinner-r40.h | 8 ++++++++ 2 files changed, 39 insertions(+), 3 deletions(-)
hw/arm/allwinner-r40.c +31 -3
@@ -45,6 +45,13 @@ const hwaddr allwinner_r40_memmap[] = { [AW_R40_DEV_CCU] = 0x01c20000, [AW_R40_DEV_PIT] = 0x01c20c00, [AW_R40_DEV_UART0] = 0x01c28000, + [AW_R40_DEV_UART1] = 0x01c28400, + [AW_R40_DEV_UART2] = 0x01c28800, + [AW_R40_DEV_UART3] = 0x01c28c00, + [AW_R40_DEV_UART4] = 0x01c29000, + [AW_R40_DEV_UART5] = 0x01c29400, + [AW_R40_DEV_UART6] = 0x01c29800, + [AW_R40_DEV_UART7] = 0x01c29c00, [AW_R40_DEV_GIC_DIST] = 0x01c81000, [AW_R40_DEV_GIC_CPU] = 0x01c82000, [AW_R40_DEV_GIC_HYP] = 0x01c84000,
@@ -157,6 +164,13 @@ enum {/* Shared Processor Interrupts */ enum {AW_R40_GIC_SPI_UART0 =1 , +AW_R40_GIC_SPI_UART1 =2 , +AW_R40_GIC_SPI_UART2 =3 , +AW_R40_GIC_SPI_UART3 =4 , +AW_R40_GIC_SPI_UART4 =17 , +AW_R40_GIC_SPI_UART5 =18 , +AW_R40_GIC_SPI_UART6 =19 , +AW_R40_GIC_SPI_UART7 =20 ,AW_R40_GIC_SPI_TIMER0 =22 ,AW_R40_GIC_SPI_TIMER1 =23 ,AW_R40_GIC_SPI_MMC0 =32 ,
@@ -384,9 +398,23 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp) }/* UART0. For future clocktree API: All UARTS are connected to APB2_CLK. */ -serial_mm_init (get_system_memory (), s->memmap[AW_R40_DEV_UART0 ],2 , -qdev_get_gpio_in (DEVICE (&s->gic),AW_R40_GIC_SPI_UART0 ), -115200 ,serial_hd (0 ),DEVICE_NATIVE_ENDIAN ); +for (int i =0 ; i <AW_R40_NUM_UARTS ; i++) { +static const int uart_irqs[AW_R40_NUM_UARTS ] = { +AW_R40_GIC_SPI_UART0 , +AW_R40_GIC_SPI_UART1 , +AW_R40_GIC_SPI_UART2 , +AW_R40_GIC_SPI_UART3 , +AW_R40_GIC_SPI_UART4 , +AW_R40_GIC_SPI_UART5 , +AW_R40_GIC_SPI_UART6 , +AW_R40_GIC_SPI_UART7 , + }; +const hwaddr addr = s->memmap[AW_R40_DEV_UART0 + i]; + +serial_mm_init (get_system_memory (), addr,2 , +qdev_get_gpio_in (DEVICE (&s->gic), uart_irqs[i]), +115200 ,serial_hd (i),DEVICE_NATIVE_ENDIAN ); + }/* Unimplemented devices */ for (i =0 ; i <ARRAY_SIZE (r40_unimplemented); i++) {
include/hw/arm/allwinner-r40.h +8 -0
@@ -41,6 +41,13 @@ enum {AW_R40_DEV_CCU ,AW_R40_DEV_PIT ,AW_R40_DEV_UART0 , +AW_R40_DEV_UART1 , +AW_R40_DEV_UART2 , +AW_R40_DEV_UART3 , +AW_R40_DEV_UART4 , +AW_R40_DEV_UART5 , +AW_R40_DEV_UART6 , +AW_R40_DEV_UART7 ,AW_R40_DEV_GIC_DIST ,AW_R40_DEV_GIC_CPU , AW_R40_DEV_GIC_HYP,
@@ -70,6 +77,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AwR40State, AW_R40)* which are currently emulated by the R40 SoC code. */ #define AW_R40_NUM_MMCS 4 +#define AW_R40_NUM_UARTS 8struct AwR40State {/*< private >*/
Signature · 1 line
2.25.1
PATCH v5 4/11 hw: arm: allwinner-r40: Add i2c0 device
In reply to [email protected]From: qianfan Zhao <[email protected]>
TWI(i2c) is designed to be used as an interface between CPU host and the serial 2-Wire bus. It can support all standard 2-Wire transfer, can be operated in standard mode(100kbit/s) or fast-mode, supporting data rate up to 400kbit/s.
--- hw/arm/allwinner-r40.c | 11 ++++++++++- include/hw/arm/allwinner-r40.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-)
hw/arm/allwinner-r40.c +10 -1
@@ -52,6 +52,7 @@ const hwaddr allwinner_r40_memmap[] = { [AW_R40_DEV_UART5] = 0x01c29400, [AW_R40_DEV_UART6] = 0x01c29800, [AW_R40_DEV_UART7] = 0x01c29c00, + [AW_R40_DEV_TWI0] = 0x01c2ac00, [AW_R40_DEV_GIC_DIST] = 0x01c81000, [AW_R40_DEV_GIC_CPU] = 0x01c82000, [AW_R40_DEV_GIC_HYP] = 0x01c84000,
@@ -115,7 +116,6 @@ static struct AwR40Unimplemented r40_unimplemented[] = { { "uart7", 0x01c29c00, 1 * KiB }, { "ps20", 0x01c2a000, 1 * KiB }, { "ps21", 0x01c2a400, 1 * KiB }, - { "twi0", 0x01c2ac00, 1 * KiB }, { "twi1", 0x01c2b000, 1 * KiB }, { "twi2", 0x01c2b400, 1 * KiB }, { "twi3", 0x01c2b800, 1 * KiB },
@@ -167,6 +167,7 @@ enum {AW_R40_GIC_SPI_UART1 =2 ,AW_R40_GIC_SPI_UART2 =3 ,AW_R40_GIC_SPI_UART3 =4 , +AW_R40_GIC_SPI_TWI0 =7 ,AW_R40_GIC_SPI_UART4 =17 ,AW_R40_GIC_SPI_UART5 =18 , AW_R40_GIC_SPI_UART6 = 19,
@@ -270,6 +271,8 @@ static void allwinner_r40_init(Object *obj)object_initialize_child (obj, mmc_names[i], &s->mmc[i],TYPE_AW_SDHOST_SUN5I ); } + +object_initialize_child (obj,"twi0" , &s->i2c0,TYPE_AW_I2C_SUN6I ); }static void allwinner_r40_realize (DeviceState *dev,Error **errp)
@@ -416,6 +419,12 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp) 115200, serial_hd(i), DEVICE_NATIVE_ENDIAN); } +/* I2C */ +sysbus_realize (SYS_BUS_DEVICE (&s->i2c0), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->i2c0),0 , s->memmap[AW_R40_DEV_TWI0 ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c0),0 , +qdev_get_gpio_in (DEVICE (&s->gic),AW_R40_GIC_SPI_TWI0 )); +/* Unimplemented devices */ for (i =0 ; i <ARRAY_SIZE (r40_unimplemented); i++) { create_unimplemented_device(r40_unimplemented[i].device_name,
include/hw/arm/allwinner-r40.h +3 -0
@@ -26,6 +26,7 @@#include "hw/intc/arm_gic.h" #include "hw/sd/allwinner-sdhost.h" #include "hw/misc/allwinner-r40-ccu.h" +#include "hw/i2c/allwinner-i2c.h" #include "target/arm/cpu.h" #include "sysemu/block-backend.h"
@@ -48,6 +49,7 @@ enum {AW_R40_DEV_UART5 ,AW_R40_DEV_UART6 ,AW_R40_DEV_UART7 , +AW_R40_DEV_TWI0 ,AW_R40_DEV_GIC_DIST ,AW_R40_DEV_GIC_CPU , AW_R40_DEV_GIC_HYP,
@@ -89,6 +91,7 @@ struct AwR40State {AwA10PITState timer;AwSdHostState mmc[AW_R40_NUM_MMCS ];AwR40ClockCtlState ccu; +AWI2CState i2c0;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
Signature · 1 line
2.25.1
PATCH v5 5/11 hw/misc: Rename axp209 to axp22x and add support AXP221 PMU
In reply to [email protected]From: qianfan Zhao <[email protected]>
This patch adds minimal support for AXP-221 PMU and connect it to bananapi M2U board.
--- hw/arm/Kconfig | 3 +- hw/arm/bananapi_m2u.c | 6 + hw/misc/Kconfig | 2 +- hw/misc/axp209.c | 238 ----------------------------------- hw/misc/axp2xx.c | 283 ++++++++++++++++++++++++++++++++++++++++++ hw/misc/meson.build | 2 +- hw/misc/trace-events | 8 +- 7 files changed, 297 insertions(+), 245 deletions(-) delete mode 100644 hw/misc/axp209.c create mode 100644 hw/misc/axp2xx.c
hw/arm/Kconfig +2 -1
@@ -355,7 +355,7 @@ config ALLWINNER_A10 select ALLWINNER_WDT select ALLWINNER_EMAC select ALLWINNER_I2C - select AXP209_PMU + select AXP2XX_PMU select SERIAL select UNIMP
@@ -378,6 +378,7 @@ config ALLWINNER_R40 bool default y if TCG && ARM select ALLWINNER_A10_PIT + select AXP2XX_PMU select SERIAL select ARM_TIMER select ARM_GIC
hw/arm/bananapi_m2u.c +6 -0
@@ -23,6 +23,7 @@#include "qapi/error.h" #include "qemu/error-report.h" #include "hw/boards.h" +#include "hw/i2c/i2c.h" #include "hw/qdev-properties.h" #include "hw/arm/allwinner-r40.h"
@@ -61,6 +62,7 @@ static void bpim2u_init(MachineState *machine) {bool bootroom_loaded = false;AwR40State *r40; +I2CBus *i2c;/* BIOS is not supported by this board */ if (machine->firmware) {
@@ -104,6 +106,10 @@ static void bpim2u_init(MachineState *machine) } } +/* Connect AXP221 */ + i2c =I2C_BUS (qdev_get_child_bus (DEVICE (&r40->i2c0),"i2c" )); +i2c_slave_create_simple (i2c,"axp221_pmu" ,0x34 ); +/* SDRAM */ memory_region_add_subregion (get_system_memory (), r40->memmap[AW_R40_DEV_SDRAM ], machine->ram);
hw/misc/Kconfig +1 -1
@@ -176,7 +176,7 @@ config ALLWINNER_A10_CCM config ALLWINNER_A10_DRAMC bool -config AXP209_PMU +config AXP2XX_PMU bool depends on I2C
hw/misc/axp209.c deleted +0 -238
238 lines not on this page · raw message
hw/misc/axp2xx.c new file +283 -0
283 lines not on this page · raw message
hw/misc/meson.build +1 -1
@@ -45,7 +45,7 @@ softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-sysctrl.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sid.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40-ccu.c')) -softmmu_ss.add(when: 'CONFIG_AXP209_PMU', if_true: files('axp209.c')) +softmmu_ss.add(when: 'CONFIG_AXP2XX_PMU', if_true: files('axp2xx.c')) softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('arm_sysctl.c')) softmmu_ss.add(when: 'CONFIG_NSERIES', if_true: files('cbus.c')) softmmu_ss.add(when: 'CONFIG_ECCMEMCTL', if_true: files('eccmemctl.c'))
hw/misc/trace-events +4 -4
@@ -23,10 +23,10 @@ allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" avr_power_read(uint8_t value) "power_reduc read value:%u" avr_power_write(uint8_t value) "power_reduc write value:%u" -# axp209.c -axp209_rx(uint8_t reg, uint8_t data) "Read reg 0x%" PRIx8 " : 0x%" PRIx8 -axp209_select(uint8_t reg) "Accessing reg 0x%" PRIx8 -axp209_tx(uint8_t reg, uint8_t data) "Write reg 0x%" PRIx8 " : 0x%" PRIx8 +# axp2xx +axp2xx_rx(uint8_t reg, uint8_t data) "Read reg 0x%" PRIx8 " : 0x%" PRIx8 +axp2xx_select(uint8_t reg) "Accessing reg 0x%" PRIx8 +axp2xx_tx(uint8_t reg, uint8_t data) "Write reg 0x%" PRIx8 " : 0x%" PRIx8 # eccmemctl.c ecc_mem_writel_mer(uint32_t val) "Write memory enable 0x%08x"
Signature · 1 line
2.25.1
PATCH v5 6/11 hw/arm/allwinner-r40: add SDRAM controller device
In reply to [email protected]From: qianfan Zhao <[email protected]>
Types of memory that the SDRAM controller supports are DDR2/DDR3 and capacities of up to 2GiB. This commit adds emulation support of the Allwinner R40 SDRAM controller.
This driver only support 256M, 512M and 1024M memory now.
--- hw/arm/allwinner-r40.c | 21 +- hw/arm/bananapi_m2u.c | 7 + hw/misc/allwinner-r40-dramc.c | 513 ++++++++++++++++++++++++++ hw/misc/meson.build | 1 + hw/misc/trace-events | 14 + include/hw/arm/allwinner-r40.h | 13 +- include/hw/misc/allwinner-r40-dramc.h | 108 ++++++ 7 files changed, 674 insertions(+), 3 deletions(-) create mode 100644 hw/misc/allwinner-r40-dramc.c create mode 100644 include/hw/misc/allwinner-r40-dramc.h
hw/arm/allwinner-r40.c +19 -2
@@ -31,6 +31,7 @@#include "hw/loader.h" #include "sysemu/sysemu.h" #include "hw/arm/allwinner-r40.h" +#include "hw/misc/allwinner-r40-dramc.h" /* Memory map */ const hwaddr allwinner_r40_memmap[] = {
@@ -53,6 +54,9 @@ const hwaddr allwinner_r40_memmap[] = { [AW_R40_DEV_UART6] = 0x01c29800, [AW_R40_DEV_UART7] = 0x01c29c00, [AW_R40_DEV_TWI0] = 0x01c2ac00, + [AW_R40_DEV_DRAMCOM] = 0x01c62000, + [AW_R40_DEV_DRAMCTL] = 0x01c63000, + [AW_R40_DEV_DRAMPHY] = 0x01c65000, [AW_R40_DEV_GIC_DIST] = 0x01c81000, [AW_R40_DEV_GIC_CPU] = 0x01c82000, [AW_R40_DEV_GIC_HYP] = 0x01c84000,
@@ -129,8 +133,6 @@ static struct AwR40Unimplemented r40_unimplemented[] = { { "gpu", 0x01c40000, 64 * KiB }, { "gmac", 0x01c50000, 64 * KiB }, { "hstmr", 0x01c60000, 4 * KiB }, - { "dram-com", 0x01c62000, 4 * KiB }, - { "dram-ctl", 0x01c63000, 4 * KiB }, { "tcon-top", 0x01c70000, 4 * KiB }, { "lcd0", 0x01c71000, 4 * KiB }, { "lcd1", 0x01c72000, 4 * KiB },
@@ -273,6 +275,12 @@ static void allwinner_r40_init(Object *obj) }object_initialize_child (obj,"twi0" , &s->i2c0,TYPE_AW_I2C_SUN6I ); + +object_initialize_child (obj,"dramc" , &s->dramc,TYPE_AW_R40_DRAMC ); +object_property_add_alias (obj,"ram-addr" ,OBJECT (&s->dramc), +"ram-addr" ); +object_property_add_alias (obj,"ram-size" ,OBJECT (&s->dramc), +"ram-size" ); }static void allwinner_r40_realize (DeviceState *dev,Error **errp)
@@ -425,6 +433,15 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp)sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c0),0 ,qdev_get_gpio_in (DEVICE (&s->gic),AW_R40_GIC_SPI_TWI0 )); +/* DRAMC */ +sysbus_realize (SYS_BUS_DEVICE (&s->dramc), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),0 , + s->memmap[AW_R40_DEV_DRAMCOM ]); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),1 , + s->memmap[AW_R40_DEV_DRAMCTL ]); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),2 , + s->memmap[AW_R40_DEV_DRAMPHY ]); +/* Unimplemented devices */ for (i =0 ; i <ARRAY_SIZE (r40_unimplemented); i++) { create_unimplemented_device(r40_unimplemented[i].device_name,
hw/arm/bananapi_m2u.c +7 -0
@@ -85,6 +85,13 @@ static void bpim2u_init(MachineState *machine)object_property_set_int (OBJECT (r40),"clk1-freq" ,24 *1000 *1000 , &error_abort); +/* DRAMC */ + r40->ram_size = machine->ram_size / MiB; +object_property_set_uint (OBJECT (r40),"ram-addr" , + r40->memmap[AW_R40_DEV_SDRAM ], &error_abort); +object_property_set_int (OBJECT (r40),"ram-size" , + r40->ram_size, &error_abort); +/* Mark R40 object realized */ qdev_realize (DEVICE (r40),NULL , &error_abort);
hw/misc/allwinner-r40-dramc.c new file +513 -0
513 lines not on this page · raw message
hw/misc/meson.build +1 -0
@@ -45,6 +45,7 @@ softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-dramc.c softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-sysctrl.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sid.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40-ccu.c')) +softmmu_ss.add(when: 'CONFIG_ALLWINNER_R40', if_true: files('allwinner-r40-dramc.c')) softmmu_ss.add(when: 'CONFIG_AXP2XX_PMU', if_true: files('axp2xx.c')) softmmu_ss.add(when: 'CONFIG_REALVIEW', if_true: files('arm_sysctl.c')) softmmu_ss.add(when: 'CONFIG_NSERIES', if_true: files('cbus.c'))
hw/misc/trace-events +14 -0
@@ -15,6 +15,20 @@ allwinner_h3_dramctl_write(uint64_t offset, uint64_t data, unsigned size) "Write allwinner_h3_dramphy_read(uint64_t offset, uint64_t data, unsigned size) "Read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 allwinner_h3_dramphy_write(uint64_t offset, uint64_t data, unsigned size) "write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +# allwinner-r40-dramc.c +allwinner_r40_dramc_detect_cells_disable(void) "Disable detect cells" +allwinner_r40_dramc_detect_cells_enable(void) "Enable detect cells" +allwinner_r40_dramc_map_rows(uint8_t row_bits, uint8_t bank_bits, uint8_t col_bits) "DRAM layout: row_bits %d, bank_bits %d, col_bits %d" +allwinner_r40_dramc_offset_to_cell(uint64_t offset, int row, int bank, int col) "offset 0x%" PRIx64 " row %d bank %d col %d" +allwinner_r40_dramc_detect_cell_write(uint64_t offset, uint64_t data) "offset 0x%" PRIx64 " data 0x%" PRIx64 "" +allwinner_r40_dramc_detect_cell_read(uint64_t offset, uint64_t data) "offset 0x%" PRIx64 " data 0x%" PRIx64 "" +allwinner_r40_dramcom_read(uint64_t offset, uint64_t data, unsigned size) "Read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_r40_dramcom_write(uint64_t offset, uint64_t data, unsigned size) "Write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_r40_dramctl_read(uint64_t offset, uint64_t data, unsigned size) "Read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_r40_dramctl_write(uint64_t offset, uint64_t data, unsigned size) "Write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_r40_dramphy_read(uint64_t offset, uint64_t data, unsigned size) "Read: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +allwinner_r40_dramphy_write(uint64_t offset, uint64_t data, unsigned size) "write: offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 + # allwinner-sid.c allwinner_sid_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32
include/hw/arm/allwinner-r40.h +12 -1
@@ -26,6 +26,7 @@#include "hw/intc/arm_gic.h" #include "hw/sd/allwinner-sdhost.h" #include "hw/misc/allwinner-r40-ccu.h" +#include "hw/misc/allwinner-r40-dramc.h" #include "hw/i2c/allwinner-i2c.h" #include "target/arm/cpu.h" #include "sysemu/block-backend.h"
@@ -54,7 +55,10 @@ enum {AW_R40_DEV_GIC_CPU ,AW_R40_DEV_GIC_HYP ,AW_R40_DEV_GIC_VCPU , - AW_R40_DEV_SDRAM +AW_R40_DEV_SDRAM , +AW_R40_DEV_DRAMCOM , +AW_R40_DEV_DRAMCTL , + AW_R40_DEV_DRAMPHY, };#define AW_R40_NUM_CPUS (4)
@@ -86,11 +90,18 @@ struct AwR40State {DeviceState parent_obj;/*< public >*/ +/** Physical base address for start of RAM */ +hwaddr ram_addr; + +/** Total RAM size in megabytes */ +uint32_t ram_size; +ARMCPU cpus[AW_R40_NUM_CPUS ];const hwaddr *memmap;AwA10PITState timer;AwSdHostState mmc[AW_R40_NUM_MMCS ];AwR40ClockCtlState ccu; +AwR40DramCtlState dramc;AWI2CState i2c0;GICState gic;MemoryRegion sram_a1;
include/hw/misc/allwinner-r40-dramc.h new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 7/11 hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
In reply to [email protected]From: qianfan Zhao <[email protected]>
A64's sd register was similar to H3, and it introduced a new register named SAMP_DL_REG location at 0x144. The dma descriptor buffer size of mmc2 is only 8K and the other mmc controllers has 64K.
Also fix allwinner-r40's mmc controller type.
--- hw/arm/allwinner-r40.c | 2 +- hw/sd/allwinner-sdhost.c | 72 ++++++++++++++++++++++++++++++-- include/hw/sd/allwinner-sdhost.h | 9 ++++ 3 files changed, 79 insertions(+), 4 deletions(-)
hw/arm/allwinner-r40.c +1 -1
@@ -271,7 +271,7 @@ static void allwinner_r40_init(Object *obj)for (int i =0 ; i <AW_R40_NUM_MMCS ; i++) {object_initialize_child (obj, mmc_names[i], &s->mmc[i], -TYPE_AW_SDHOST_SUN5I ); +TYPE_AW_SDHOST_SUN50I_A64 ); }object_initialize_child (obj,"twi0" , &s->i2c0,TYPE_AW_I2C_SUN6I );
hw/sd/allwinner-sdhost.c +69 -3
158 lines not on this page · raw message
include/hw/sd/allwinner-sdhost.h +9 -0
@@ -38,6 +38,12 @@/** Allwinner sun5i family and newer (A13, H2+, H3, etc) */ #define TYPE_AW_SDHOST_SUN5I TYPE_AW_SDHOST "-sun5i" +/** Allwinner sun50i-a64 */ +#define TYPE_AW_SDHOST_SUN50I_A64 TYPE_AW_SDHOST "-sun50i-a64" + +/** Allwinner sun50i-a64 emmc */ +#define TYPE_AW_SDHOST_SUN50I_A64_EMMC TYPE_AW_SDHOST "-sun50i-a64-emmc" +/** @} */ /**
@@ -110,6 +116,7 @@ struct AwSdHostState {uint32_t startbit_detect;/**< eMMC DDR Start Bit Detection Control */ uint32_t response_crc;/**< Response CRC */ uint32_t data_crc[8 ];/**< Data CRC */ +uint32_t sample_delay;/**< Sample delay control */ uint32_t status_crc;/**< Status CRC */ /** @} */
@@ -132,6 +139,8 @@ struct AwSdHostClass {size_t max_desc_size;bool is_sun4i; +/** does the IP block support autocalibration? */ + bool can_calibrate; };#endif /* HW_SD_ALLWINNER_SDHOST_H */
Signature · 1 line
2.25.1
PATCH v5 8/11 hw: arm: allwinner-r40: Add emac and gmac support
In reply to [email protected]From: qianfan Zhao <[email protected]>
R40 has two ethernet controllers named as emac and gmac. The emac is compatibled with A10, and the GMAC is compatibled with H3.
--- hw/arm/allwinner-r40.c | 50 ++++++++++++++++++++++++++++++++-- hw/arm/bananapi_m2u.c | 3 ++ include/hw/arm/allwinner-r40.h | 6 ++++ 3 files changed, 57 insertions(+), 2 deletions(-)
hw/arm/allwinner-r40.c +48 -2
@@ -39,6 +39,7 @@ const hwaddr allwinner_r40_memmap[] = { [AW_R40_DEV_SRAM_A2] = 0x00004000, [AW_R40_DEV_SRAM_A3] = 0x00008000, [AW_R40_DEV_SRAM_A4] = 0x0000b400, + [AW_R40_DEV_EMAC] = 0x01c0b000, [AW_R40_DEV_MMC0] = 0x01c0f000, [AW_R40_DEV_MMC1] = 0x01c10000, [AW_R40_DEV_MMC2] = 0x01c11000,
@@ -54,6 +55,7 @@ const hwaddr allwinner_r40_memmap[] = { [AW_R40_DEV_UART6] = 0x01c29800, [AW_R40_DEV_UART7] = 0x01c29c00, [AW_R40_DEV_TWI0] = 0x01c2ac00, + [AW_R40_DEV_GMAC] = 0x01c50000, [AW_R40_DEV_DRAMCOM] = 0x01c62000, [AW_R40_DEV_DRAMCTL] = 0x01c63000, [AW_R40_DEV_DRAMPHY] = 0x01c65000,
@@ -82,7 +84,6 @@ static struct AwR40Unimplemented r40_unimplemented[] = { { "spi1", 0x01c06000, 4 * KiB }, { "cs0", 0x01c09000, 4 * KiB }, { "keymem", 0x01c0a000, 4 * KiB }, - { "emac", 0x01c0b000, 4 * KiB }, { "usb0-otg", 0x01c13000, 4 * KiB }, { "usb0-host", 0x01c14000, 4 * KiB }, { "crypto", 0x01c15000, 4 * KiB },
@@ -131,7 +132,6 @@ static struct AwR40Unimplemented r40_unimplemented[] = { { "tvd2", 0x01c33000, 4 * KiB }, { "tvd3", 0x01c34000, 4 * KiB }, { "gpu", 0x01c40000, 64 * KiB }, - { "gmac", 0x01c50000, 64 * KiB }, { "hstmr", 0x01c60000, 4 * KiB }, { "tcon-top", 0x01c70000, 4 * KiB }, { "lcd0", 0x01c71000, 4 * KiB },
@@ -180,6 +180,8 @@ enum {AW_R40_GIC_SPI_MMC1 =33 ,AW_R40_GIC_SPI_MMC2 =34 ,AW_R40_GIC_SPI_MMC3 =35 , +AW_R40_GIC_SPI_EMAC =55 , + AW_R40_GIC_SPI_GMAC = 85, };/* Allwinner R40 general constants */
@@ -276,6 +278,11 @@ static void allwinner_r40_init(Object *obj)object_initialize_child (obj,"twi0" , &s->i2c0,TYPE_AW_I2C_SUN6I ); +object_initialize_child (obj,"emac" , &s->emac,TYPE_AW_EMAC ); +object_initialize_child (obj,"gmac" , &s->gmac,TYPE_AW_SUN8I_EMAC ); +object_property_add_alias (obj,"gmac-phy-addr" , +OBJECT (&s->gmac),"phy-addr" ); +object_initialize_child (obj,"dramc" , &s->dramc,TYPE_AW_R40_DRAMC );object_property_add_alias (obj,"ram-addr" ,OBJECT (&s->dramc),"ram-addr" );
@@ -285,6 +292,7 @@ static void allwinner_r40_init(Object *obj)static void allwinner_r40_realize (DeviceState *dev,Error **errp) { +const char *r40_nic_models[] = {"gmac" ,"emac" ,NULL };AwR40State *s =AW_R40 (dev);unsigned i;
@@ -442,6 +450,44 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp)sysbus_mmio_map (SYS_BUS_DEVICE (&s->dramc),2 , s->memmap[AW_R40_DEV_DRAMPHY ]); +/* nic support gmac and emac */ +for (int i =0 ; i <ARRAY_SIZE (r40_nic_models) -1 ; i++) { +NICInfo *nic = &nd_table[i]; + +if (!nic->used) { +continue ; + } +if (qemu_show_nic_models (nic->model, r40_nic_models)) { +exit (0 ); + } + +switch (qemu_find_nic_model (nic, r40_nic_models, r40_nic_models[0 ])) { +case 0 :/* gmac */ +qdev_set_nic_properties (DEVICE (&s->gmac), nic); +break ; +case 1 :/* emac */ +qdev_set_nic_properties (DEVICE (&s->emac), nic); +break ; +default : +exit (1 ); +break ; + } + } + +/* GMAC */ +object_property_set_link (OBJECT (&s->gmac),"dma-memory" , +OBJECT (get_system_memory ()), &error_fatal); +sysbus_realize (SYS_BUS_DEVICE (&s->gmac), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->gmac),0 , s->memmap[AW_R40_DEV_GMAC ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->gmac),0 , +qdev_get_gpio_in (DEVICE (&s->gic),AW_R40_GIC_SPI_GMAC )); + +/* EMAC */ +sysbus_realize (SYS_BUS_DEVICE (&s->emac), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->emac),0 , s->memmap[AW_R40_DEV_EMAC ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->emac),0 , +qdev_get_gpio_in (DEVICE (&s->gic),AW_R40_GIC_SPI_EMAC )); +/* Unimplemented devices */ for (i =0 ; i <ARRAY_SIZE (r40_unimplemented); i++) { create_unimplemented_device(r40_unimplemented[i].device_name,
hw/arm/bananapi_m2u.c +3 -0
@@ -92,6 +92,9 @@ static void bpim2u_init(MachineState *machine)object_property_set_int (OBJECT (r40),"ram-size" , r40->ram_size, &error_abort); +/* GMAC PHY */ +object_property_set_uint (OBJECT (r40),"gmac-phy-addr" ,1 , &error_abort); +/* Mark R40 object realized */ qdev_realize (DEVICE (r40),NULL , &error_abort);
include/hw/arm/allwinner-r40.h +6 -0
@@ -28,6 +28,8 @@#include "hw/misc/allwinner-r40-ccu.h" #include "hw/misc/allwinner-r40-dramc.h" #include "hw/i2c/allwinner-i2c.h" +#include "hw/net/allwinner_emac.h" +#include "hw/net/allwinner-sun8i-emac.h" #include "target/arm/cpu.h" #include "sysemu/block-backend.h"
@@ -36,6 +38,7 @@ enum {AW_R40_DEV_SRAM_A2 ,AW_R40_DEV_SRAM_A3 ,AW_R40_DEV_SRAM_A4 , +AW_R40_DEV_EMAC ,AW_R40_DEV_MMC0 ,AW_R40_DEV_MMC1 , AW_R40_DEV_MMC2,
@@ -51,6 +54,7 @@ enum {AW_R40_DEV_UART6 ,AW_R40_DEV_UART7 ,AW_R40_DEV_TWI0 , +AW_R40_DEV_GMAC ,AW_R40_DEV_GIC_DIST ,AW_R40_DEV_GIC_CPU , AW_R40_DEV_GIC_HYP,
@@ -103,6 +107,8 @@ struct AwR40State {AwR40ClockCtlState ccu;AwR40DramCtlState dramc;AWI2CState i2c0; +AwEmacState emac; +AwSun8iEmacState gmac;GICState gic;MemoryRegion sram_a1;MemoryRegion sram_a2;
Signature · 1 line
2.25.1
PATCH v5 9/11 hw: arm: allwinner-sramc: Add SRAM Controller support for R40
In reply to [email protected]From: qianfan Zhao <[email protected]>
Only a few important registers are added, especially the SRAM_VER register.
--- hw/arm/Kconfig | 1 + hw/arm/allwinner-r40.c | 7 +- hw/misc/Kconfig | 3 + hw/misc/allwinner-sramc.c | 184 ++++++++++++++++++++++++++++++ hw/misc/meson.build | 1 + hw/misc/trace-events | 4 + include/hw/arm/allwinner-r40.h | 3 + include/hw/misc/allwinner-sramc.h | 69 +++++++++++ 8 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 hw/misc/allwinner-sramc.c create mode 100644 include/hw/misc/allwinner-sramc.h
hw/arm/Kconfig +1 -0
@@ -377,6 +377,7 @@ config ALLWINNER_H3 config ALLWINNER_R40 bool default y if TCG && ARM + select ALLWINNER_SRAMC select ALLWINNER_A10_PIT select AXP2XX_PMU select SERIAL
hw/arm/allwinner-r40.c +6 -1
@@ -39,6 +39,7 @@ const hwaddr allwinner_r40_memmap[] = { [AW_R40_DEV_SRAM_A2] = 0x00004000, [AW_R40_DEV_SRAM_A3] = 0x00008000, [AW_R40_DEV_SRAM_A4] = 0x0000b400, + [AW_R40_DEV_SRAMC] = 0x01c00000, [AW_R40_DEV_EMAC] = 0x01c0b000, [AW_R40_DEV_MMC0] = 0x01c0f000, [AW_R40_DEV_MMC1] = 0x01c10000,
@@ -76,7 +77,6 @@ struct AwR40Unimplemented {static struct AwR40Unimplemented r40_unimplemented[] = { {"d-engine" ,0x01000000 ,4 * MiB }, {"d-inter" ,0x01400000 ,128 * KiB }, - {"sram-c" ,0x01c00000 ,4 * KiB }, {"dma" ,0x01c02000 ,4 * KiB }, {"nfdc" ,0x01c03000 ,4 * KiB }, {"ts" ,0x01c04000 ,4 * KiB },
@@ -288,6 +288,8 @@ static void allwinner_r40_init(Object *obj) "ram-addr");object_property_add_alias (obj,"ram-size" ,OBJECT (&s->dramc),"ram-size" ); + +object_initialize_child (obj,"sramc" , &s->sramc,TYPE_AW_SRAMC_SUN8I_R40 ); }static void allwinner_r40_realize (DeviceState *dev,Error **errp)
@@ -382,6 +384,9 @@ static void allwinner_r40_realize(DeviceState *dev, Error **errp) AW_R40_GIC_SPI_TIMER1));/* SRAM */ +sysbus_realize (SYS_BUS_DEVICE (&s->sramc), &error_fatal); +sysbus_mmio_map (SYS_BUS_DEVICE (&s->sramc),0 , s->memmap[AW_R40_DEV_SRAMC ]); +memory_region_init_ram (&s->sram_a1,OBJECT (dev),"sram A1" ,16 * KiB, &error_abort); memory_region_init_ram(&s->sram_a2, OBJECT(dev), "sram A2",
hw/misc/Kconfig +3 -0
@@ -170,6 +170,9 @@ config VIRT_CTRL config LASI bool +config ALLWINNER_SRAMC + bool + config ALLWINNER_A10_CCM bool
hw/misc/allwinner-sramc.c new file +184 -0
184 lines not on this page · raw message
hw/misc/meson.build +1 -0
@@ -37,6 +37,7 @@ subdir('macio') softmmu_ss.add(when: 'CONFIG_IVSHMEM_DEVICE', if_true: files('ivshmem.c')) +softmmu_ss.add(when: 'CONFIG_ALLWINNER_SRAMC', if_true: files('allwinner-sramc.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_CCM', if_true: files('allwinner-a10-ccm.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_A10_DRAMC', if_true: files('allwinner-a10-dramc.c')) softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-h3-ccu.c'))
hw/misc/trace-events +4 -0
@@ -33,6 +33,10 @@ allwinner_r40_dramphy_write(uint64_t offset, uint64_t data, unsigned size) "writ allwinner_sid_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 allwinner_sid_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 +# allwinner-sramc.c +allwinner_sramc_read(uint64_t offset, uint64_t data) "offset 0x%" PRIx64 " data 0x%" PRIx64 +allwinner_sramc_write(uint64_t offset, uint64_t data) "offset 0x%" PRIx64 " data 0x%" PRIx64 + # avr_power.c avr_power_read(uint8_t value) "power_reduc read value:%u" avr_power_write(uint8_t value) "power_reduc write value:%u"
include/hw/arm/allwinner-r40.h +3 -0
@@ -27,6 +27,7 @@#include "hw/sd/allwinner-sdhost.h" #include "hw/misc/allwinner-r40-ccu.h" #include "hw/misc/allwinner-r40-dramc.h" +#include "hw/misc/allwinner-sramc.h" #include "hw/i2c/allwinner-i2c.h" #include "hw/net/allwinner_emac.h" #include "hw/net/allwinner-sun8i-emac.h"
@@ -38,6 +39,7 @@ enum {AW_R40_DEV_SRAM_A2 ,AW_R40_DEV_SRAM_A3 ,AW_R40_DEV_SRAM_A4 , +AW_R40_DEV_SRAMC ,AW_R40_DEV_EMAC ,AW_R40_DEV_MMC0 , AW_R40_DEV_MMC1,
@@ -102,6 +104,7 @@ struct AwR40State {ARMCPU cpus[AW_R40_NUM_CPUS ];const hwaddr *memmap; +AwSRAMCState sramc;AwA10PITState timer;AwSdHostState mmc[AW_R40_NUM_MMCS ];AwR40ClockCtlState ccu;
include/hw/misc/allwinner-sramc.h new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v5 10/11 tests: avocado: boot_linux_console: Add test case for bpim2u
In reply to [email protected]From: qianfan Zhao <[email protected]>
Add test case for booting from initrd and sd card.
--- tests/avocado/boot_linux_console.py | 176 ++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+)
tests/avocado/boot_linux_console.py +176 -0
@@ -769,6 +769,182 @@ def test_arm_quanta_gsj_initrd(self): self.wait_for_console_pattern( 'Give root password for system maintenance') + def test_arm_bpim2u(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:bpim2u + :avocado: tags=accel:tcg + """ + deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/' + 'linux-image-current-sunxi_21.02.2_armhf.deb') + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, + '/boot/vmlinuz-5.10.16-sunxi') + dtb_path = ('/usr/lib/linux-image-current-sunxi/' + 'sun8i-r40-bananapi-m2-ultra.dtb') + dtb_path = self.extract_from_deb(deb_path, dtb_path) + + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0,115200n8 ' + 'earlycon=uart,mmio32,0x1c28000') + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-append', kernel_command_line) + self.vm.launch() + console_pattern = 'Kernel command line: %s' % kernel_command_line + self.wait_for_console_pattern(console_pattern) + + def test_arm_bpim2u_initrd(self): + """ + :avocado: tags=arch:arm + :avocado: tags=accel:tcg + :avocado: tags=machine:bpim2u + """ + deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/' + 'linux-image-current-sunxi_21.02.2_armhf.deb') + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, + '/boot/vmlinuz-5.10.16-sunxi') + dtb_path = ('/usr/lib/linux-image-current-sunxi/' + 'sun8i-r40-bananapi-m2-ultra.dtb') + dtb_path = self.extract_from_deb(deb_path, dtb_path) + initrd_url = ('https://github.com/groeck/linux-build-test/raw/' + '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' + 'arm/rootfs-armv7a.cpio.gz') + initrd_hash = '604b2e45cdf35045846b8bbfbf2129b1891bdc9c' + initrd_path_gz = self.fetch_asset(initrd_url, asset_hash=initrd_hash) + initrd_path = os.path.join(self.workdir, 'rootfs.cpio') + archive.gzip_uncompress(initrd_path_gz, initrd_path) + + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0,115200 ' + 'panic=-1 noreboot') + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-initrd', initrd_path, + '-append', kernel_command_line, + '-no-reboot') + self.vm.launch() + self.wait_for_console_pattern('Boot successful.') + + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'Allwinner sun8i Family') + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', + 'system-control@1c00000') + exec_command_and_wait_for_pattern(self, 'reboot', + 'reboot: Restarting system') + # Wait for VM to shut down gracefully + self.vm.wait() + + def test_arm_bpim2u_gmac(self): + """ + :avocado: tags=arch:arm + :avocado: tags=accel:tcg + :avocado: tags=machine:bpim2u + :avocado: tags=device:sd + """ + self.require_netdev('user') + + deb_url = ('https://apt.armbian.com/pool/main/l/linux-5.10.16-sunxi/' + 'linux-image-current-sunxi_21.02.2_armhf.deb') + deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' + deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) + kernel_path = self.extract_from_deb(deb_path, + '/boot/vmlinuz-5.10.16-sunxi') + dtb_path = ('/usr/lib/linux-image-current-sunxi/' + 'sun8i-r40-bananapi-m2-ultra.dtb') + dtb_path = self.extract_from_deb(deb_path, dtb_path) + rootfs_url = ('http://storage.kernelci.org/images/rootfs/buildroot/' + 'buildroot-baseline/20221116.0/armel/rootfs.ext2.xz') + rootfs_hash = 'fae32f337c7b87547b10f42599acf109da8b6d9a' + rootfs_path_xz = self.fetch_asset(rootfs_url, asset_hash=rootfs_hash) + rootfs_path = os.path.join(self.workdir, 'rootfs.cpio') + archive.lzma_uncompress(rootfs_path_xz, rootfs_path) + image_pow2ceil_expand(rootfs_path) + + self.vm.set_console() + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'console=ttyS0,115200 ' + 'root=/dev/mmcblk0 rootwait rw ' + 'panic=-1 noreboot') + self.vm.add_args('-kernel', kernel_path, + '-dtb', dtb_path, + '-drive', 'file=' + rootfs_path + ',if=sd,format=raw', + '-net', 'nic,model=gmac,netdev=host_gmac', + '-netdev', 'user,id=host_gmac', + '-append', kernel_command_line, + '-no-reboot') + self.vm.launch() + shell_ready = "/bin/sh: can't access tty; job control turned off" + self.wait_for_console_pattern(shell_ready) + + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'Allwinner sun8i Family') + exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', + 'mmcblk0') + exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up', + 'eth0: Link is Up') + exec_command_and_wait_for_pattern(self, 'udhcpc eth0', + 'udhcpc: lease of 10.0.2.15 obtained') + exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', + '3 packets transmitted, 3 packets received, 0% packet loss') + exec_command_and_wait_for_pattern(self, 'reboot', + 'reboot: Restarting system') + # Wait for VM to shut down gracefully + self.vm.wait() + + @skipUnless(os.getenv('AVOCADO_ALLOW_LARGE_STORAGE'), 'storage limited') + def test_arm_bpim2u_openwrt_22_03_3(self): + """ + :avocado: tags=arch:arm + :avocado: tags=machine:bpim2u + :avocado: tags=device:sd + """ + + # This test download a 8.9 MiB compressed image and expand it + # to 127 MiB. + image_url = ('https://downloads.openwrt.org/releases/22.03.3/targets/' + 'sunxi/cortexa7/openwrt-22.03.3-sunxi-cortexa7-' + 'sinovoip_bananapi-m2-ultra-ext4-sdcard.img.gz') + image_hash = ('5b41b4e11423e562c6011640f9a7cd3b' + 'dd0a3d42b83430f7caa70a432e6cd82c') + image_path_gz = self.fetch_asset(image_url, asset_hash=image_hash, + algorithm='sha256') + image_path = archive.extract(image_path_gz, self.workdir) + image_pow2ceil_expand(image_path) + + self.vm.set_console() + self.vm.add_args('-drive', 'file=' + image_path + ',if=sd,format=raw', + '-nic', 'user', + '-no-reboot') + self.vm.launch() + + kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + + 'usbcore.nousb ' + 'noreboot') + + self.wait_for_console_pattern('U-Boot SPL') + + interrupt_interactive_console_until_pattern( + self, 'Hit any key to stop autoboot:', '=>') + exec_command_and_wait_for_pattern(self, "setenv extraargs '" + + kernel_command_line + "'", '=>') + exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...'); + + self.wait_for_console_pattern( + 'Please press Enter to activate this console.') + + exec_command_and_wait_for_pattern(self, ' ', 'root@') + + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'Allwinner sun8i Family') + exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', + 'system-control@1c00000') + def test_arm_orangepi(self): """ :avocado: tags=arch:arm
Signature · 1 line
2.25.1
Hi Qianfan,
Thanks for sending the v5. From my side, I have no further comments on the content.
So please feel free to add the following to each of the patches 01-11 in the series:
As a reminder and explained here on this page, you'll need to make sure these lines gets added to each of the commit messages:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#proper-use-of-reviewed-by-tags-can-aid-review
Doing so would require you to send another updated v6, and baselined on the latest master.
Thanks again for contributing this to Qemu, hopefully we can see it merged soon.
Regards,
Niek
Quoted 95 lines · On Tue, May 23, 2023 at 12:05 PM <[email protected]> wrote:
From: qianfan Zhao <[email protected]>
***History***
# v1: 2023-03-21The first version which add allwinner-r40 support, supported features:
+ ccu
+ dram controller
+ uart
+ i2c and pmic(axp221)
+ sdcard
+ emac/gmacAlso provide a test case under avocado, running quickly test:
$ AVOCADO_ALLOW_LARGE_STORAGE=yes tests/venv/bin/avocado \ --verbose --show=app,console run -t machine:bpim2u \ ../tests/avocado/boot_linux_console.py# v2: 2023-03-28
1. Fix the waring and error reported by checkpatch.pl
2. Remove the other i2c controllers except that i2c0
3. Use an array to register mmc and uart devices
4. Rename axp209 to axp22x and add axp221 support
5. Add a basic SRAM controller# v3: 2023-04-18
1. Update some commit messages
2. Squash those two commit about sdcard
hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
hw: arm: allwinner-r40: Fix the mmc controller's type# v4: 2023-05-10
1. Rebase to master
# v5: 2023-05-23
1. Rebase to master
2. Update based on Niek Linnenbank's guide.qianfan Zhao (11):
hw: arm: Add bananapi M2-Ultra and allwinner-r40 support hw/arm/allwinner-r40: add Clock Control Unit
hw: allwinner-r40: Complete uart devices
hw: arm: allwinner-r40: Add i2c0 device
hw/misc: Rename axp209 to axp22x and add support AXP221 PMU hw/arm/allwinner-r40: add SDRAM controller device
hw: sd: allwinner-sdhost: Add sun50i-a64 SoC support
hw: arm: allwinner-r40: Add emac and gmac support
hw: arm: allwinner-sramc: Add SRAM Controller support for R40
tests: avocado:boot_linux_console: Add test case for bpim2u
docs: system: arm: Introducebananapi_m2udocs/system/arm/bananapi_m2u.rst | 138 +++++++ hw/arm/Kconfig | 14 +- hw/arm/allwinner-r40.c | 526 ++++++++++++++++++++++++++ hw/arm/bananapi_m2u.c | 145 +++++++ hw/arm/meson.build | 1 + hw/misc/Kconfig | 5 +- hw/misc/allwinner-r40-ccu.c | 209 ++++++++++ hw/misc/allwinner-r40-dramc.c | 513 +++++++++++++++++++++++++ hw/misc/allwinner-sramc.c | 184 +++++++++ hw/misc/axp209.c | 238 ------------ hw/misc/axp2xx.c | 283 ++++++++++++++ hw/misc/meson.build | 5 +- hw/misc/trace-events | 26 +- hw/sd/allwinner-sdhost.c | 72 +++- include/hw/arm/allwinner-r40.h | 143 +++++++ include/hw/misc/allwinner-r40-ccu.h | 65 ++++ include/hw/misc/allwinner-r40-dramc.h | 108 ++++++ include/hw/misc/allwinner-sramc.h | 69 ++++ include/hw/sd/allwinner-sdhost.h | 9 + tests/avocado/boot_linux_console.py | 176 +++++++++ 20 files changed, 2681 insertions(+), 248 deletions(-) create mode 100644 docs/system/arm/bananapi_m2u.rst create mode 100644 hw/arm/allwinner-r40.c create mode 100644 hw/arm/bananapi_m2u.c create mode 100644 hw/misc/allwinner-r40-ccu.c create mode 100644 hw/misc/allwinner-r40-dramc.c create mode 100644 hw/misc/allwinner-sramc.c delete mode 100644 hw/misc/axp209.c create mode 100644 hw/misc/axp2xx.c create mode 100644 include/hw/arm/allwinner-r40.h create mode 100644 include/hw/misc/allwinner-r40-ccu.h create mode 100644 include/hw/misc/allwinner-r40-dramc.h create mode 100644 include/hw/misc/allwinner-sramc.h--
2.25.1
Signature · 1 line
Niek Linnenbank
Quoted 6 lines · Niek Linnenbank
Hi Qianfan,
Thanks for sending the v5. From my side, I have no further comments on the content. So please feel free to add the following to each of the patches 01-11 in the series:
Quoted 6 lines
Reviewed-by Niek Linnenbank <[email protected]>As a reminder and explained here on this page, you'll need to make sure these lines gets added to each of the commit messages:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#proper-use-of-reviewed-by-tags-can-aid-reviewDoing so would require you to send another updated v6, and baselined on the latest master.
The rebase was simple, so I've applied this v5 to target-arm.next. (The patch application tools can pick up Reviewed-by tags that are on-list without requiring a respin just for that.)
Qianfan: thanks for working on this feature and for your efforts in working through our patch review process.
Niek: thanks very much for taking the lead on the patch review of this series, it's been a tremendous help.
-- PMM
Hi Peter, Qianfan,
Quoted 13 lines · Peter Maydell
Quoted 4 lines · Niek Linnenbank
Hi Qianfan,
Thanks for sending the v5. From my side, I have no further comments on
the content.
Quoted 1 line
So please feel free to add the following to each of the patches 01-11 in
the series:
Quoted 4 lines
Reviewed-by Niek Linnenbank <[email protected]>As a reminder and explained here on this page, you'll need to make sure
Quoted 9 lines
these lines gets added to each of the commit messages:
Quoted 1 line
Quoted 2 lines
Doing so would require you to send another updated v6, and baselined on
the latest master.
The rebase was simple, so I've applied this v5 to target-arm.next.
Great news!
Quoted 3 lines
(The patch application tools can pick up Reviewed-by tags that are on-list without requiring a respin just for that.)
Ahh right, I wasn't aware of that. Thanks, I learned something new here.
Quoted 4 lines
Qianfan: thanks for working on this feature and for your efforts in working through our patch review process.
Yes, great work indeed!
Quoted 4 lines
Niek: thanks very much for taking the lead on the patch review of this series, it's been a tremendous help.
I'm glad to help. I only do qemu work in my spare time when I can, so it's not much.
But I enjoy doing it and learn something new in the process also.
Regards,
Niek
Quoted 3 lines
-- PMM
Signature · 1 line
Niek Linnenbank