qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Modeling a device controlled by combination of GPIO and


From: Peter Maydell
Subject: Re: [Qemu-devel] Modeling a device controlled by combination of GPIO and UART
Date: Tue, 21 Aug 2018 14:56:54 +0100

On 21 August 2018 at 14:29, Martin Schroeder via Qemu-devel
<address@hidden> wrote:
> I'd like to add a virtual device that is controlled by a couple of
> GPIO pins on my controller (cortex-m4) and a serial port. I suppose I
> can derive it from SSISlaveClass to make the new device a serial
> slave.
>
> But how do I connect GPIOs?
>
> I want the slave device to be notified when guest firmware toggles a
> gpio pin through the gpio driver which is an mmio device mapped into
> the gpio memory area. So the GPIO driver currently keeps the state of
> the pins internal to the driver. What I would like to do is somehow,
> without requiring that the GPIO driver knows about the connected slave
> device, deliver the notification of a gpio pin being toggled to the
> slave device.

The GPIO device should expose its outbound GPIO lines
as qdev gpio lines. The slave device should have a GPIO line
which is an input qdev gpio. The board code then connects the two
together using
  qdev_connect_gpio_out(your_gpio_device, i,
                        qdev_get_gpio_in(slavedevice, j));

which connects the GPIO controller's output GPIO i to
slave device's input GPIO j.

There are also _named() versions of these so you can
give GPIO lines names rather than having them be unnamed
(which makes the code a bit easier to understand, especially
where the device isn't a gpio controller whose outputs are
all just "the GPIO lines").

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]