[Qemu-devel] [PATCH v3 0/4] bcm2835: add sdhost and gpio controllers

Clement Deschamps posted 4 patches 7 years, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170224164021.9066-1-clement.deschamps@antfield.fr
Test checkpatch passed
Test docker passed
Test s390x passed
hw/arm/bcm2835_peripherals.c         |  43 +++-
hw/gpio/Makefile.objs                |   1 +
hw/gpio/bcm2835_gpio.c               | 353 ++++++++++++++++++++++++++++
hw/sd/Makefile.objs                  |   1 +
hw/sd/bcm2835_sdhost.c               | 429 +++++++++++++++++++++++++++++++++++
hw/sd/core.c                         |  30 +++
include/hw/arm/bcm2835_peripherals.h |   4 +
include/hw/gpio/bcm2835_gpio.h       |  39 ++++
include/hw/sd/bcm2835_sdhost.h       |  48 ++++
include/hw/sd/sd.h                   |   1 +
10 files changed, 947 insertions(+), 2 deletions(-)
create mode 100644 hw/gpio/bcm2835_gpio.c
create mode 100644 hw/sd/bcm2835_sdhost.c
create mode 100644 include/hw/gpio/bcm2835_gpio.h
create mode 100644 include/hw/sd/bcm2835_sdhost.h
[Qemu-devel] [PATCH v3 0/4] bcm2835: add sdhost and gpio controllers
Posted by Clement Deschamps 7 years, 2 months ago
This patches add the Arasan SDHost controller and the GPIO controller to the BCM2835/36 platforms.

This patches have been tested with raspbian 2015-09-24 (which uses the SDHCI controller),
and raspbian 2017-01-11 (which dynamically switches to the SDHost controller).


I spotted an issue with the raspi2 platform, but it is not related to this patch.
The CP15 timer frequency is set to 19.20MHz in the raspbian kernel DTB.
There is a constant (GTIMER_SCALE) in target/arm/internals.h which seems to tell that the timer is at 62.5MHz.
This causes problems:
- The sleep command entered in guest lasts around 1/3 of the time it is supposed to last.
- The cursor is blinking faster that it should
- The systemd timeouts expire too early.          
- ...

Did you already have this issue on another platform ?
Should the frequency in the DTB be dynamically replaced depending on the GTIMER_SCALE value ?
Or should the constant GTIMER_SCALE be platform dependent ?


v2:
- implements the GPIO controller for supporting SD controller selection via alternate functions of GPIOs 48-53

v3:
- removed unneeded alias (sd-bus-2)
- changed license to GPLv2 'or later'
- moved the sdbus_reparent_card() function to hw/sd/core.c
- added 'readonly' state propagation in sdbus_reparent_card()
- the gpio controller is now exposing an sdbus and has 2 references to sdbus of sdhci and sdhost controllers

Clement Deschamps (4):
  bcm2835_sdhost: add bcm2835 sdhost controller
  hw/sd: add card-reparenting function
  bcm2835_gpio: add bcm2835 gpio controller
  bcm2835: add sdhost and gpio controllers

 hw/arm/bcm2835_peripherals.c         |  43 +++-
 hw/gpio/Makefile.objs                |   1 +
 hw/gpio/bcm2835_gpio.c               | 353 ++++++++++++++++++++++++++++
 hw/sd/Makefile.objs                  |   1 +
 hw/sd/bcm2835_sdhost.c               | 429 +++++++++++++++++++++++++++++++++++
 hw/sd/core.c                         |  30 +++
 include/hw/arm/bcm2835_peripherals.h |   4 +
 include/hw/gpio/bcm2835_gpio.h       |  39 ++++
 include/hw/sd/bcm2835_sdhost.h       |  48 ++++
 include/hw/sd/sd.h                   |   1 +
 10 files changed, 947 insertions(+), 2 deletions(-)
 create mode 100644 hw/gpio/bcm2835_gpio.c
 create mode 100644 hw/sd/bcm2835_sdhost.c
 create mode 100644 include/hw/gpio/bcm2835_gpio.h
 create mode 100644 include/hw/sd/bcm2835_sdhost.h

-- 
2.11.1


Re: [Qemu-devel] [PATCH v3 0/4] bcm2835: add sdhost and gpio controllers
Posted by Peter Maydell 7 years, 1 month ago
On 24 February 2017 at 16:40, Clement Deschamps
<clement.deschamps@antfield.fr> wrote:
> This patches add the Arasan SDHost controller and the GPIO controller to the BCM2835/36 platforms.
>
> This patches have been tested with raspbian 2015-09-24 (which uses the SDHCI controller),
> and raspbian 2017-01-11 (which dynamically switches to the SDHost controller).

Thanks; applied to target-arm.next; I'll put out a pullreq either today
or tomorrow with these in.

> I spotted an issue with the raspi2 platform, but it is not related to this patch.
> The CP15 timer frequency is set to 19.20MHz in the raspbian kernel DTB.
> There is a constant (GTIMER_SCALE) in target/arm/internals.h which seems to tell that the timer is at 62.5MHz.
> This causes problems:
> - The sleep command entered in guest lasts around 1/3 of the time it is supposed to last.
> - The cursor is blinking faster that it should
> - The systemd timeouts expire too early.
> - ...
>
> Did you already have this issue on another platform ?
> Should the frequency in the DTB be dynamically replaced depending on the GTIMER_SCALE value ?
> Or should the constant GTIMER_SCALE be platform dependent ?

We haven't noticed that on other platforms -- I think typically the kernel
trusts the value in the cp15 "what frequency are the timers" register,
at least on the "virt" board which gets the most usage.

We probably should have a mechanism for allowing the SoC or
board to set the clock frequency for the timer registers, though.
Ideally this would be done with the clocktree patchset that
Fred Konrad has been working on, which provides a generic
mechanism for wiring up "clocks" to devices which tell them how
fast things should tick.

thanks
-- PMM