Skip to content

Commit b549147

Browse files
gaojunhao0504wenlingz
authored andcommitted
doc: add virtio-gpio doc
add virtio-gpio doc Signed-off-by: Gao Junhao <junhao.gao@intel.com>
1 parent 5466c8e commit b549147

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

doc/developer-guides/hld/hld-virtio-devices.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,8 @@ their temporary IDs are listed in the following table.
753753
+--------------+-------------+-------------+-------------+-------------+
754754
| I2C | 0x8086 | 0x860a | 0x8086 | 0xFFF6 |
755755
+--------------+-------------+-------------+-------------+-------------+
756+
| GPIO | 0x8086 | 0x8609 | 0x8086 | 0xFFF7 |
757+
+--------------+-------------+-------------+-------------+-------------+
756758

757759
The following sections introduce the status of virtio devices currently
758760
supported in ACRN.
@@ -766,3 +768,4 @@ supported in ACRN.
766768
virtio-console
767769
virtio-rnd
768770
virtio-i2c
771+
virtio-gpio
117 KB
Loading
26 KB
Loading
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.. _virtio-gpio:
2+
3+
Virtio-gpio
4+
###########
5+
6+
virtio-gpio provides a virtual GPIO controller, which will map part of native GPIOs to UOS, UOS can perform GPIO operations through it, including setting values, including set/get value, set/get direction and set configuration (only Open Source and Open Drain types are currently supported). GPIOs quite often be used as IRQs, typically for wakeup events, virtio-gpio supports level and edge interrupt trigger modes.
7+
8+
The virtio-gpio architecture is shown below
9+
10+
.. figure:: images/virtio-gpio-1.png
11+
:align: center
12+
:name: virtio-gpio-1
13+
14+
Virtio-gpio Architecture
15+
16+
Virtio-gpio is implemented as a virtio legacy device in the ACRN device model (DM), and is registered as a PCI virtio device to the guest OS. No changes are required in the frontend Linux virtio-gpio except that the guest (UOS) kernel should be built with ``CONFIG_VIRTIO_GPIO=y``.
17+
18+
There are three virtqueues used between FE and BE, one for gpio operations, one for irq request and one for irq event notification.
19+
20+
Virtio-gpio FE driver will register a gpiochip and irqchip when it is probed, the base and number of gpio are generated by the BE. Each gpiochip or irqchip operation(e.g. get_direction of gpiochip or irq_set_type of irqchip) will trigger a virtqueue_kick on its own virtqueue. If some gpio has been set to interrupt mode, the interrupt events will be handled within the irq virtqueue callback.
21+
22+
GPIO mapping
23+
************
24+
25+
.. figure:: images/virtio-gpio-2.png
26+
:align: center
27+
:name: virtio-gpio-2
28+
29+
GPIO mapping
30+
31+
- Each UOS has only one GPIO chip instance, its number of GPIO is based on acrn-dm command line and GPIO base always start from 0.
32+
33+
- Each GPIO is exclusive, uos can’t map the same native gpio.
34+
35+
- Each acrn-dm maximum number of GPIO is 64.
36+
37+
Usage
38+
*****
39+
40+
add the following parameters into command line::
41+
42+
-s <slot>,virtio-gpio,<@controller_name{offset|name[=mapping_name]:offset|name[=mapping_name]:…}@controller_name{…}…]>
43+
44+
- **controller_name**: Input “ls /sys/bus/gpio/devices” to check native gpio controller information.Usually, the devices represent the controller_name, you can use it as controller_name directly. You can also input “cat /sys/bus/gpio/device/XXX/dev” to get device id that can be used to match /dev/XXX, then use XXX as the controller_name. On MRB and NUC platforms, the controller_name are gpiochip0, gpiochip1, gpiochip2.gpiochip3.
45+
46+
- **offset|name**: you can use gpio offset or its name to locate one native gpio within the gpio controller.
47+
48+
- **mapping_name**: This is optional, if you want to use a customized name for a FE gpio, you can set a new name for a FE virtual gpio.
49+
50+
Example
51+
*******
52+
53+
- Map three native gpio to UOS, they are native gpiochip0 with offset of 1 and 6, and with the name “reset”. In UOS, the three gpio has no name, and base from 0.::
54+
55+
-s 10,virtio-gpio,@gpiochip0{1:6:reset}
56+
57+
- Map four native gpio to UOS, native gpiochip0’s gpio with offset 1 and offset 6 map to FE virtual gpio with offset 0 and offset 1 without names, native gpiochip0’s gpio with name “reset” maps to FE virtual gpio with offset 2 and its name is “shutdown”, native gpiochip1’s gpio with offset 0 maps to FE virtual gpio with offset 3 and its name is “reset”.::
58+
59+
-s 10,virtio-gpio,@gpiochip0{1:6:reset=shutdown}@gpiochip1{0=reset}
60+

0 commit comments

Comments
 (0)