Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-2…
Browse files Browse the repository at this point in the history
…0210709' into staging

target-arm queue:
 * New machine type: stm32vldiscovery
 * hw/intc/arm_gicv3_cpuif: Fix virtual irq number check in icv_[dir|eoir]_write
 * hw/gpio/pl061: Honour Luminary PL061 PUR and PDR registers
 * virt: Fix implementation of GPIO-based powerdown/shutdown mechanism
 * Correct the encoding of MDCCSR_EL0 and DBGDSCRint
 * hw/intc: Improve formatting of MEMTX_ERROR guest error message

# gpg: Signature made Fri 09 Jul 2021 17:09:10 BST
# gpg:                using RSA key E1A5C593CD419DE28E8315CF3C2525ED14360CDE
# gpg:                issuer "peter.maydell@linaro.org"
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>" [ultimate]
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>" [ultimate]
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* remotes/pmaydell/tags/pull-target-arm-20210709:
  hw/intc: Improve formatting of MEMTX_ERROR guest error message
  target/arm: Correct the encoding of MDCCSR_EL0 and DBGDSCRint
  hw/arm/stellaris: Expand comment about handling of OLED chipselect
  hw/gpio/pl061: Document a shortcoming in our implementation
  hw/gpio/pl061: Convert to 3-phase reset and assert GPIO lines correctly on reset
  hw/arm/virt: Make PL061 GPIO lines pulled low, not high
  hw/gpio/pl061: Make pullup/pulldown of outputs configurable
  hw/gpio/pl061: Honour Luminary PL061 PUR and PDR registers
  hw/gpio/pl061: Document the interface of this device
  hw/gpio/pl061: Add tracepoints for register read and write
  hw/gpio/pl061: Clean up read/write offset handling logic
  hw/gpio/pl061: Convert DPRINTF to tracepoints
  hw/intc/arm_gicv3_cpuif: Fix virtual irq number check in icv_[dir|eoir]_write
  tests/boot-serial-test: Add STM32VLDISCOVERY board testcase
  docs/system: arm: Add stm32 boards description
  stm32vldiscovery: Add the STM32VLDISCOVERY Machine
  stm32f100: Add the stm32f100 SoC

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Jul 11, 2021
2 parents 42e1d79 + 05449ab commit 3cfcc32
Show file tree
Hide file tree
Showing 17 changed files with 792 additions and 80 deletions.
13 changes: 13 additions & 0 deletions MAINTAINERS
Expand Up @@ -893,6 +893,13 @@ F: hw/*/stellaris*
F: include/hw/input/gamepad.h
F: docs/system/arm/stellaris.rst

STM32VLDISCOVERY
M: Alexandre Iooss <erdnaxe@crans.org>
L: qemu-arm@nongnu.org
S: Maintained
F: hw/arm/stm32vldiscovery.c
F: docs/system/arm/stm32.rst

Versatile Express
M: Peter Maydell <peter.maydell@linaro.org>
L: qemu-arm@nongnu.org
Expand Down Expand Up @@ -948,6 +955,12 @@ L: qemu-arm@nongnu.org
S: Maintained
F: hw/arm/virt-acpi-build.c

STM32F100
M: Alexandre Iooss <erdnaxe@crans.org>
L: qemu-arm@nongnu.org
S: Maintained
F: hw/arm/stm32f100_soc.c

STM32F205
M: Alistair Francis <alistair@alistair23.me>
M: Peter Maydell <peter.maydell@linaro.org>
Expand Down
1 change: 1 addition & 0 deletions default-configs/devices/arm-softmmu.mak
Expand Up @@ -18,6 +18,7 @@ CONFIG_CHEETAH=y
CONFIG_SX1=y
CONFIG_NSERIES=y
CONFIG_STELLARIS=y
CONFIG_STM32VLDISCOVERY=y
CONFIG_REALVIEW=y
CONFIG_VERSATILE=y
CONFIG_VEXPRESS=y
Expand Down
66 changes: 66 additions & 0 deletions docs/system/arm/stm32.rst
@@ -0,0 +1,66 @@
STMicroelectronics STM32 boards (``netduino2``, ``netduinoplus2``, ``stm32vldiscovery``)
========================================================================================

The `STM32`_ chips are a family of 32-bit ARM-based microcontroller by
STMicroelectronics.

.. _STM32: https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html

The STM32F1 series is based on ARM Cortex-M3 core. The following machines are
based on this chip :

- ``stm32vldiscovery`` STM32VLDISCOVERY board with STM32F100RBT6 microcontroller

The STM32F2 series is based on ARM Cortex-M3 core. The following machines are
based on this chip :

- ``netduino2`` Netduino 2 board with STM32F205RFT6 microcontroller

The STM32F4 series is based on ARM Cortex-M4F core. This series is pin-to-pin
compatible with STM32F2 series. The following machines are based on this chip :

- ``netduinoplus2`` Netduino Plus 2 board with STM32F405RGT6 microcontroller

There are many other STM32 series that are currently not supported by QEMU.

Supported devices
-----------------

* ARM Cortex-M3, Cortex M4F
* Analog to Digital Converter (ADC)
* EXTI interrupt
* Serial ports (USART)
* SPI controller
* System configuration (SYSCFG)
* Timer controller (TIMER)

Missing devices
---------------

* Camera interface (DCMI)
* Controller Area Network (CAN)
* Cycle Redundancy Check (CRC) calculation unit
* Digital to Analog Converter (DAC)
* DMA controller
* Ethernet controller
* Flash Interface Unit
* GPIO controller
* I2C controller
* Inter-Integrated Sound (I2S) controller
* Power supply configuration (PWR)
* Random Number Generator (RNG)
* Real-Time Clock (RTC) controller
* Reset and Clock Controller (RCC)
* Secure Digital Input/Output (SDIO) interface
* USB OTG
* Watchdog controller (IWDG, WWDG)

Boot options
------------

The STM32 machines can be started using the ``-kernel`` option to load a
firmware. Example:

.. code-block:: bash
$ qemu-system-arm -M stm32vldiscovery -kernel firmware.bin
1 change: 1 addition & 0 deletions docs/system/target-arm.rst
Expand Up @@ -97,6 +97,7 @@ undocumented; you can get a complete list by running
arm/collie
arm/sx1
arm/stellaris
arm/stm32
arm/virt
arm/xlnx-versal-virt

Expand Down
10 changes: 10 additions & 0 deletions hw/arm/Kconfig
Expand Up @@ -239,6 +239,10 @@ config STELLARIS
select STELLARIS_ENET # ethernet
select UNIMP

config STM32VLDISCOVERY
bool
select STM32F100_SOC

config STRONGARM
bool
select PXA2XX
Expand Down Expand Up @@ -326,6 +330,12 @@ config RASPI
select SDHCI
select USB_DWC2

config STM32F100_SOC
bool
select ARM_V7M
select STM32F2XX_USART
select STM32F2XX_SPI

config STM32F205_SOC
bool
select ARM_V7M
Expand Down
2 changes: 2 additions & 0 deletions hw/arm/meson.build
Expand Up @@ -24,6 +24,7 @@ arm_ss.add(when: 'CONFIG_Z2', if_true: files('z2.c'))
arm_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview.c'))
arm_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa-ref.c'))
arm_ss.add(when: 'CONFIG_STELLARIS', if_true: files('stellaris.c'))
arm_ss.add(when: 'CONFIG_STM32VLDISCOVERY', if_true: files('stm32vldiscovery.c'))
arm_ss.add(when: 'CONFIG_COLLIE', if_true: files('collie.c'))
arm_ss.add(when: 'CONFIG_VERSATILE', if_true: files('versatilepb.c'))
arm_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c'))
Expand All @@ -39,6 +40,7 @@ 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_RASPI', if_true: files('bcm2835_peripherals.c', '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'))
arm_ss.add(when: 'CONFIG_STM32F405_SOC', if_true: files('stm32f405_soc.c'))
arm_ss.add(when: 'CONFIG_XLNX_ZYNQMP_ARM', if_true: files('xlnx-zynqmp.c', 'xlnx-zcu102.c'))
Expand Down
56 changes: 55 additions & 1 deletion hw/arm/stellaris.c
Expand Up @@ -1453,13 +1453,67 @@ static void stellaris_init(MachineState *ms, stellaris_board_info *board)
DeviceState *sddev;
DeviceState *ssddev;

/* Some boards have both an OLED controller and SD card connected to
/*
* Some boards have both an OLED controller and SD card connected to
* the same SSI port, with the SD card chip select connected to a
* GPIO pin. Technically the OLED chip select is connected to the
* SSI Fss pin. We do not bother emulating that as both devices
* should never be selected simultaneously, and our OLED controller
* ignores stray 0xff commands that occur when deselecting the SD
* card.
*
* The h/w wiring is:
* - GPIO pin D0 is wired to the active-low SD card chip select
* - GPIO pin A3 is wired to the active-low OLED chip select
* - The SoC wiring of the PL061 "auxiliary function" for A3 is
* SSI0Fss ("frame signal"), which is an output from the SoC's
* SSI controller. The SSI controller takes SSI0Fss low when it
* transmits a frame, so it can work as a chip-select signal.
* - GPIO A4 is aux-function SSI0Rx, and wired to the SD card Tx
* (the OLED never sends data to the CPU, so no wiring needed)
* - GPIO A5 is aux-function SSI0Tx, and wired to the SD card Rx
* and the OLED display-data-in
* - GPIO A2 is aux-function SSI0Clk, wired to SD card and OLED
* serial-clock input
* So a guest that wants to use the OLED can configure the PL061
* to make pins A2, A3, A5 aux-function, so they are connected
* directly to the SSI controller. When the SSI controller sends
* data it asserts SSI0Fss which selects the OLED.
* A guest that wants to use the SD card configures A2, A4 and A5
* as aux-function, but leaves A3 as a software-controlled GPIO
* line. It asserts the SD card chip-select by using the PL061
* to control pin D0, and lets the SSI controller handle Clk, Tx
* and Rx. (The SSI controller asserts Fss during tx cycles as
* usual, but because A3 is not set to aux-function this is not
* forwarded to the OLED, and so the OLED stays unselected.)
*
* The QEMU implementation instead is:
* - GPIO pin D0 is wired to the active-low SD card chip select,
* and also to the OLED chip-select which is implemented
* as *active-high*
* - SSI controller signals go to the devices regardless of
* whether the guest programs A2, A4, A5 as aux-function or not
*
* The problem with this implementation is if the guest doesn't
* care about the SD card and only uses the OLED. In that case it
* may choose never to do anything with D0 (leaving it in its
* default floating state, which reliably leaves the card disabled
* because an SD card has a pullup on CS within the card itself),
* and only set up A2, A3, A5. This for us would mean the OLED
* never gets the chip-select assert it needs. We work around
* this with a manual raise of D0 here (despite board creation
* code being the wrong place to raise IRQ lines) to put the OLED
* into an initially selected state.
*
* In theory the right way to model this would be:
* - Implement aux-function support in the PL061, with an
* extra set of AFIN and AFOUT GPIO lines (set up so that
* if a GPIO line is in auxfn mode the main GPIO in and out
* track the AFIN and AFOUT lines)
* - Wire the AFOUT for D0 up to either a line from the
* SSI controller that's pulled low around every transmit,
* or at least to an always-0 line here on the board
* - Make the ssd0323 OLED controller chipselect active-low
*/
bus = qdev_get_child_bus(dev, "ssi");

Expand Down

0 comments on commit 3cfcc32

Please sign in to comment.