[Qemu-devel] [PATCH 0/2] add bcm2835 sdhost controller to bcm2835 platform

Clement Deschamps posted 2 patches 142 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170220173430.31630-1-clement.deschamps@antfield.fr
Test checkpatch passed
Test docker passed
Test s390x passed
hw/arm/bcm2835_peripherals.c         |  24 ++
hw/arm/bcm2836.c                     |   7 +
hw/arm/raspi.c                       |  13 +-
hw/sd/Makefile.objs                  |   1 +
hw/sd/bcm2835_sdhost.c               | 429 +++++++++++++++++++++++++++++++++++
include/hw/arm/bcm2835_peripherals.h |   2 +
include/hw/sd/bcm2835_sdhost.h       |  48 ++++
7 files changed, 523 insertions(+), 1 deletion(-)
create mode 100644 hw/sd/bcm2835_sdhost.c
create mode 100644 include/hw/sd/bcm2835_sdhost.h

[Qemu-devel] [PATCH 0/2] add bcm2835 sdhost controller to bcm2835 platform

Posted by Clement Deschamps 142 weeks ago
This patches add the Arasan SD controller to the BCM2835/36 platforms.

The BCM2835/36/37 have 2 SD controllers.

The first one has an SDHCI interface and is already supported in QEMU
(hw/sd/sdhci.c), the second one is an IP from Arasan.

The latest versions of raspbian (since 2016) have a linux kernel which is using
the Arasan SD controller for better performances, and thus are not working with
the current version of QEMU.

This patch can be tested with the latest version of raspbian (2017-01-11-raspbian-jessie):
1. Extract kernel7.img and bcm2709-rpi-2-b.dtb from the first partition of 2017-01-11-raspbian-jessie.img
2. Run qemu-system-arm -M raspi2 -kernel kernel7.img -dtb bcm2709-rpi-2-b.dtb -append "rw root=/dev/mmcblk0p2 console=ttyAMA0 rootwait" -sd 2017-01-11-raspbian-jessie.img -sd 2017-01-11-raspbian-jessie.img

On the real hardware, both SD controllers are wired to the same SD card.
Selection is done via multi-function pins through the GPIO controller.  I'm not
sure what would be the good solution to emulate this in QEMU.  For now on we
pass two sd cards on the command line which is not ideal.

Note: In order to properly boot the kernel, you will first need to apply the
BCM2835 hardware RNG patch submitted recently.

Once raspbian has booted, the mouse and keyboard cannot be used in the
graphical environment because the USB is not yet implemented in the raspberry
pi emulation. Gregory Estrade and Andrew Baumann both worked on the USB
implementation, their work is available on Andrew's github.


Best regards,

Clement Deschamps

Clement Deschamps (2):
  bcm2835_sdhost: add bcm2835 sdhost controller
  bcm2835: add bcm2835_sdhost to bcm2835 platform

 hw/arm/bcm2835_peripherals.c         |  24 ++
 hw/arm/bcm2836.c                     |   7 +
 hw/arm/raspi.c                       |  13 +-
 hw/sd/Makefile.objs                  |   1 +
 hw/sd/bcm2835_sdhost.c               | 429 +++++++++++++++++++++++++++++++++++
 include/hw/arm/bcm2835_peripherals.h |   2 +
 include/hw/sd/bcm2835_sdhost.h       |  48 ++++
 7 files changed, 523 insertions(+), 1 deletion(-)
 create mode 100644 hw/sd/bcm2835_sdhost.c
 create mode 100644 include/hw/sd/bcm2835_sdhost.h

-- 
2.11.0


Re: [Qemu-devel] [PATCH 0/2] add bcm2835 sdhost controller to bcm2835 platform

Posted by Peter Maydell 142 weeks ago
On 20 February 2017 at 17:34, Clement Deschamps
<clement.deschamps@antfield.fr> wrote:
> This patches add the Arasan SD controller to the BCM2835/36 platforms.

Cool!

> On the real hardware, both SD controllers are wired to the same SD card.
> Selection is done via multi-function pins through the GPIO controller.  I'm not
> sure what would be the good solution to emulate this in QEMU.  For now on we
> pass two sd cards on the command line which is not ideal.

That's unfortunate. I think we definitely need to fix this before we
can take the controller support into QEMU, because of the user-visible
effects on the required QEMU command line syntax.

I wonder if we can model this by effectively ejecting the card from
one SDBus and inserting it into the other when the GPIO controller
setting is configured. I think the way we want to do this is to
remove the SDState object from one SDBus qbus and insert it into
the other -- the functions in hw/sd/core.c all already cope with
"there's no card on this bus".

This might be a bit awkward because we effectively want to do a
hotplug/hot-unplug from our code but we don't want to expose to
the user that the device is hotpluggable. It may just be a matter
of doing an object_unparent() and then qdev_set_parent_bus() to move
the card object from one bus to the other... or it could get more
complicated.

thanks
-- PMM