SlideShare a Scribd company logo
ACRN GPIO Mediator Introduction
LIU Long
Liu, Long <Long.Liu@intel.com>
05/27/2020
Table of Contents
PART 1: GPIO Overview
PART 2: GPIO Virtualization
PART 3: GPIO IRQ Virtualization
PART 4: Q & A
PIN & GPIO
➱ PINs are equal to pads, fingers, balls or whatever packaging input or output line you want to
control. PINs can sometimes be software-configured in various ways, mostly related to their
electronic properties, such as biasing and drive strength, when used as inputs or outputs. PINs
also support multiplexing, it means device can set PINs to one specific function, such as GPIO,
SPI or I2C.
➱ GPIO stands for “General Purpose Input/Output”, is a flexible software-controlled digital signal.
Each GPIO represents a bit connected to a particular pin, or "ball" on Ball Grid Array(BGA)
packages and it supports some capabilities including GPIO enabled/disabled, input values are
readable(typically high or low), output values are writable/readable and input values can often be
used as IRQs (typically for wakeup events).
https://en.wikipedia.org/wiki/General-purpose_input/output
GPIO hardware logic block
SOC
Pin
Configuration
Logic Block
SPI Logic
Block
I2C Logic
Block
Multiplexer
Physical
Pin
GPIO Logic
Block
➱ Type1 - GPIO, Multiplexer and Pin
Configuration are isolated, and each
model has its own MMIO.
➱ Type 2 - GPIO, Multiplexer and Pin
Configuration are merged into single
controller, all of them has same MMIO
range. GPIO Logic
Block
Type 2
Type 1
GPIO subsystem architecture
static struct pinmux_ops foo_pmxops = {
.get_functions_count = foo_get_functions_count,
.get_function_name = foo_get_fname,
.get_function_groups = foo_get_groups,
.set_mux = foo_set_mux,
.strict = true,
};
static struct pinconf_ops foo_pconf_ops = {
.pin_config_get = foo_pin_config_get,
.pin_config_set = foo_pin_config_set,
.pin_config_group_get = foo_pin_config_group_get,
.pin_config_group_set = foo_pin_config_group_set,
};
static struct gpio_chip foo_gpio_chip = {
.get_direction= foo_get_direction,
.direction_input = foo_direction_input,
.direction_output = foo_direction_output,
.get = foo_get,
.set = foo_set,
.base = 0,
.ngpio = 64,


};
GPIO virtualization
➱ Full virtualization solution needs to provide full functionality registers to UOS, but lots of
them have no real functionality due to only assigned virtual GPIO links to physical GPIO,
and another risk is that there is no common physical GPIO controller as reference for all
UOS platforms.
➱ Para virtualization solution can be as one common solution for all future platforms.
‱ GPIO virtualization follows the Virtual I/O Device (virtio) specification.
‱ The virtual pins information and the number of pins can be configured through acrn-dm command line.
‱ No kernel space mediator support due to high risk for SOS kernel stability.
virtio-gpio architecture
https://projectacrn.github.io/latest/developer-guides/hld/hld-virtio-devices.html?highlight=virtio
Native GPIO
Virtualization GPIO
virtio-gpio virtual gpio chip
➱ Each UOS has only one
GPIO chip instance, its
number of GPIOs is based
on acrn-dm command line
and GPIO base always
start from 0.
➱ Each acrn-dm may be able
to access one or more
native GPIO chips and all
GPIOs are exclusive.
virtio-gpio how to access GPIO in UOS
int xx_pci_probe(struct pci_dev *dev, const struct
pci_device_id *id) {
struct gpio_desc *desc;
int ret, val;


desc = gpiod_get_index(dev->dev, "reset-gpios",
0,GPIOD_IN);
or
desc = gpiod_get_index(dev->dev, NULL, 0, GPIOD_IN);
if (!desc || gpiod_direction_input(desc))
goto err;
val = gpiod_get_value(desc);
...
}
virtio-gpio gpio mapping
GPIO Description table
Native
GPIO
name
Native
GPIO
chip
Native
GPIO
offset
Virtual
GPIO
offset
reset 0 10 2
shutdown 0 100 0
virtio-gpio how to access
GPIO from userspace
sysfs:
For example :
cd /sys/class/gpio
echo 9 > export
echo 0 > gpio9/value
cat gpio9/value
echo 9 > unexport
char device
For example :
void write_value(unsigned offset, int value) {
struct gpiohandle_request req;
int ret, fd;


fd = open(“/dev/gpiochip0”, O_RDWR);
memset(&req, 0, sizeof(req));
req.lineoffsets[0] = offset;
req.default_values[0] = value;
req.flags = GPIOHANDLE_REQUEST_OUTPUT;
req.lines = 1;
ret = ioctl(line->chip->fd, GPIO_GET_LINEHANDLE_IOCTL, &req);


}
GPIO IRQ Virtualization
/dev/gpiochipN
Virtio-GPIO
DM
Virtio-GPIO
FE driver
UOS
IRQ consumer
Request IRQ
Request IRQ
Apply the IRQ
IRQ event notification
Send IRQ information
Invoke consumer’s IRQ handler
Free IRQ
Release IRQ
Free the IRQ line event
Send IRQ information
Return fd
Start to poll IRQ event
IRQ event notification
IRQ event notification
Invoke consumer’s IRQ handler

 Allocate buff
Allocate buff




Usage
⚫ <gpio resources>
<@controller_name{offset|name[=mapping_name]:offset|name[=mapping_name]:
}@controller_name{
}
]>
E.g.
1. Map native gpio numbers are 1 and 6, plus one gpio its name is “reset” to frontend, all of them are defined in
GPIO controller 0
<@gpiochip0{1:6:reset}>
2. Map native gpio numbers are 1 and 6, which are in gpio controller 0, and native gpio numbers are 2 and 7, which
are in gpio controller 1.
<@gpiochip0{1:6}@gpiochip1{2:7}>
⚫ [ | acpi resources]
[|@device_name{gpio_identifier[=apci name]:gpio_identifier[=apci name]
@device_name{
}
}]
E.g.
1. Usb FE driver wants to access “reset” gpio, and it is GPIO controller 0’s “reset” GPIO in native.
<@gpiochip0{reset}|@usb{gpiochip0_reset}
2. Usb FE driver wants to access “reset” gpio, and its offset is 2 in the native GPIO controller 0.
<@gpiochip0{2}|@usb{gpiochip0_2=reset}
‱
Q & A

More Related Content

PDF
Project ACRN USB mediator introduction
PDF
Project ACRN I2C mediator introduction
PDF
ACRN vMeet-Up EU 2021 - debug ACRN hypervisor
PDF
Project ACRN EtherCAT 101
PPTX
Linux I2C
PDF
Kernel Recipes 2014 - Testing Video4Linux Applications and Drivers
PDF
ELC North America 2021 Introduction to pin muxing and gpio control under linux
PDF
Lee 2020 what the clock !
Project ACRN USB mediator introduction
Project ACRN I2C mediator introduction
ACRN vMeet-Up EU 2021 - debug ACRN hypervisor
Project ACRN EtherCAT 101
Linux I2C
Kernel Recipes 2014 - Testing Video4Linux Applications and Drivers
ELC North America 2021 Introduction to pin muxing and gpio control under linux
Lee 2020 what the clock !

What's hot (20)

PDF
Kernel Recipes 2013 - Overview display in the Linux kernel
PDF
Project ACRN CPU sharing BVT scheduler in ACRN hypervisor
PDF
I2c drivers
PDF
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
 
PDF
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
PDF
Trusted firmware deep_dive_v1.0_
 
PPT
Introduction to Vortex86DX2 Motion-Control Evaluation Board
PDF
Note - (EDK2) Acpi Tables Compile and Install
PDF
ACRN vMeet-Up EU 2021 - Real Time Management and Performance Optimization
PPT
Introduction to Android G Sensor IÂČC Driver on Android
PDF
Let's Play STM32
PDF
Linux Conference Australia 2018 : Device Tree, past, present, future
PDF
LAS16-403: GDB Linux Kernel Awareness
 
PDF
VHDL Practical Exam Guide
PDF
Andes RISC-V processor solutions
PDF
Interrupts
PDF
ELC-E 2016 Neil Armstrong - No, it's never too late to upstream your legacy l...
PDF
Elc Europe 2020 : u-boot- porting and maintaining a bootloader for a multimed...
PDF
Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203
 
Kernel Recipes 2013 - Overview display in the Linux kernel
Project ACRN CPU sharing BVT scheduler in ACRN hypervisor
I2c drivers
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
 
OSMC 2014: Server Hardware Monitoring done right | Werner Fischer
Trusted firmware deep_dive_v1.0_
 
Introduction to Vortex86DX2 Motion-Control Evaluation Board
Note - (EDK2) Acpi Tables Compile and Install
ACRN vMeet-Up EU 2021 - Real Time Management and Performance Optimization
Introduction to Android G Sensor IÂČC Driver on Android
Let's Play STM32
Linux Conference Australia 2018 : Device Tree, past, present, future
LAS16-403: GDB Linux Kernel Awareness
 
VHDL Practical Exam Guide
Andes RISC-V processor solutions
Interrupts
ELC-E 2016 Neil Armstrong - No, it's never too late to upstream your legacy l...
Elc Europe 2020 : u-boot- porting and maintaining a bootloader for a multimed...
Reliability, Availability, and Serviceability (RAS) on ARM64 status - SFO17-203
 
Ad

Similar to Project ACRN GPIO mediator introduction (20)

PDF
Atomic pi Mini PC
PDF
Atomic PI apug
PDF
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
PDF
PPT+.pdf
PDF
Ins and Outs of GPIO Programming
 
PPTX
Part-1 : Mastering microcontroller with embedded driver development
PPTX
F9 microkernel app development part 2 gpio meets led
PDF
Openwrt, linux e GPIO al LinuxDay 2010 Roma
PPTX
Interfacing two wire adc0831 to raspberry pi2 / Pi3
PDF
Run Go applications on Pico using TinyGo
PDF
Raspberry Pi dan Alat Parkir UI
PDF
Getting Started With Raspberry Pi - UCSD 2013
PDF
Linux+sensor+device-tree+shell=IoT !
PDF
Raspberry pi lcd-shield20x4
PPTX
By Asst.Prof.D.R.Bhise Electrical Engineering Department Matoshri College of ...
PDF
Raspberry Pi - HW/SW Application Development
PPTX
Roll your own toy unix clone os
 
PPT
RaspberryPI PPT WITH ALL THE DETAILS OF PROGRAMMING
DOCX
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
PPT
Led blinking using TMS320C6745
Atomic pi Mini PC
Atomic PI apug
Kernel Recipes 2018 - New GPIO interface for linux user space - Bartosz Golas...
PPT+.pdf
Ins and Outs of GPIO Programming
 
Part-1 : Mastering microcontroller with embedded driver development
F9 microkernel app development part 2 gpio meets led
Openwrt, linux e GPIO al LinuxDay 2010 Roma
Interfacing two wire adc0831 to raspberry pi2 / Pi3
Run Go applications on Pico using TinyGo
Raspberry Pi dan Alat Parkir UI
Getting Started With Raspberry Pi - UCSD 2013
Linux+sensor+device-tree+shell=IoT !
Raspberry pi lcd-shield20x4
By Asst.Prof.D.R.Bhise Electrical Engineering Department Matoshri College of ...
Raspberry Pi - HW/SW Application Development
Roll your own toy unix clone os
 
RaspberryPI PPT WITH ALL THE DETAILS OF PROGRAMMING
# peripheral registers .equ PWR_BASE0x40007000 .equ PWR_CR0x00 .docx
Led blinking using TMS320C6745
Ad

More from Project ACRN (20)

PDF
ACRN vMeet-Up EU 2021 - installation and configuration introduction
PDF
ACRN vMeet-Up EU 2021 - Bridging Orchestrator and Hard Realtime Workload Cons...
PDF
ACRN vMeet-Up EU 2021 - Boot Process and Secure Boot
PDF
ACRN vMeet-Up EU 2021 - functional safety design and certification plan
PDF
ACRN vMeet-Up EU 2021 - community and development model
PDF
ACRN vMeet-Up EU 2021 - hypervisor new platform enabling
PDF
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
PDF
ACRN vMeet-Up EU 2021 - Introduction and Architecture Look Forward
PDF
ACRN Kata Container on ACRN
PDF
Project ACRN Yocto Project meta-acrn layer introduction
PDF
Project ACRN system debug
PDF
Project ACRN SR-IOV on ACRN
PDF
Project ACRN Device Model architecture introduction
PDF
Project ACRN configuration scenarios and config tool
PDF
Project ACRN hypervisor introduction
PDF
Project ACRN how to build a Yocto Project-based SOS
PDF
Project ACRN expose and pass through platform hidden PCIe devices to SOS
PDF
Project ACRN GVT-d introduction and tutorial
PDF
Project ACRN schedule framework introduction
PDF
Project ACRN Device Passthrough Introduction
ACRN vMeet-Up EU 2021 - installation and configuration introduction
ACRN vMeet-Up EU 2021 - Bridging Orchestrator and Hard Realtime Workload Cons...
ACRN vMeet-Up EU 2021 - Boot Process and Secure Boot
ACRN vMeet-Up EU 2021 - functional safety design and certification plan
ACRN vMeet-Up EU 2021 - community and development model
ACRN vMeet-Up EU 2021 - hypervisor new platform enabling
ACRN vMeet-Up EU 2021 - shared memory based inter-vm communication introduction
ACRN vMeet-Up EU 2021 - Introduction and Architecture Look Forward
ACRN Kata Container on ACRN
Project ACRN Yocto Project meta-acrn layer introduction
Project ACRN system debug
Project ACRN SR-IOV on ACRN
Project ACRN Device Model architecture introduction
Project ACRN configuration scenarios and config tool
Project ACRN hypervisor introduction
Project ACRN how to build a Yocto Project-based SOS
Project ACRN expose and pass through platform hidden PCIe devices to SOS
Project ACRN GVT-d introduction and tutorial
Project ACRN schedule framework introduction
Project ACRN Device Passthrough Introduction

Recently uploaded (20)

PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
history of c programming in notes for students .pptx
PPTX
Introduction to Artificial Intelligence
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPT
Introduction Database Management System for Course Database
PDF
Digital Strategies for Manufacturing Companies
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
System and Network Administraation Chapter 3
PDF
top salesforce developer skills in 2025.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Softaken Excel to vCard Converter Software.pdf
Nekopoi APK 2025 free lastest update
PTS Company Brochure 2025 (1).pdf.......
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Design an Analysis of Algorithms I-SECS-1021-03
How to Migrate SBCGlobal Email to Yahoo Easily
history of c programming in notes for students .pptx
Introduction to Artificial Intelligence
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
 
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Introduction Database Management System for Course Database
Digital Strategies for Manufacturing Companies
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
ManageIQ - Sprint 268 Review - Slide Deck
System and Network Administraation Chapter 3
top salesforce developer skills in 2025.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises

Project ACRN GPIO mediator introduction

  • 1. ACRN GPIO Mediator Introduction LIU Long Liu, Long <Long.Liu@intel.com> 05/27/2020
  • 2. Table of Contents PART 1: GPIO Overview PART 2: GPIO Virtualization PART 3: GPIO IRQ Virtualization PART 4: Q & A
  • 3. PIN & GPIO ➱ PINs are equal to pads, fingers, balls or whatever packaging input or output line you want to control. PINs can sometimes be software-configured in various ways, mostly related to their electronic properties, such as biasing and drive strength, when used as inputs or outputs. PINs also support multiplexing, it means device can set PINs to one specific function, such as GPIO, SPI or I2C. ➱ GPIO stands for “General Purpose Input/Output”, is a flexible software-controlled digital signal. Each GPIO represents a bit connected to a particular pin, or "ball" on Ball Grid Array(BGA) packages and it supports some capabilities including GPIO enabled/disabled, input values are readable(typically high or low), output values are writable/readable and input values can often be used as IRQs (typically for wakeup events). https://en.wikipedia.org/wiki/General-purpose_input/output
  • 4. GPIO hardware logic block SOC Pin Configuration Logic Block SPI Logic Block I2C Logic Block Multiplexer Physical Pin GPIO Logic Block ➱ Type1 - GPIO, Multiplexer and Pin Configuration are isolated, and each model has its own MMIO. ➱ Type 2 - GPIO, Multiplexer and Pin Configuration are merged into single controller, all of them has same MMIO range. GPIO Logic Block Type 2 Type 1
  • 5. GPIO subsystem architecture static struct pinmux_ops foo_pmxops = { .get_functions_count = foo_get_functions_count, .get_function_name = foo_get_fname, .get_function_groups = foo_get_groups, .set_mux = foo_set_mux, .strict = true, }; static struct pinconf_ops foo_pconf_ops = { .pin_config_get = foo_pin_config_get, .pin_config_set = foo_pin_config_set, .pin_config_group_get = foo_pin_config_group_get, .pin_config_group_set = foo_pin_config_group_set, }; static struct gpio_chip foo_gpio_chip = { .get_direction= foo_get_direction, .direction_input = foo_direction_input, .direction_output = foo_direction_output, .get = foo_get, .set = foo_set, .base = 0, .ngpio = 64, 
 };
  • 6. GPIO virtualization ➱ Full virtualization solution needs to provide full functionality registers to UOS, but lots of them have no real functionality due to only assigned virtual GPIO links to physical GPIO, and another risk is that there is no common physical GPIO controller as reference for all UOS platforms. ➱ Para virtualization solution can be as one common solution for all future platforms. ‱ GPIO virtualization follows the Virtual I/O Device (virtio) specification. ‱ The virtual pins information and the number of pins can be configured through acrn-dm command line. ‱ No kernel space mediator support due to high risk for SOS kernel stability.
  • 10. virtio-gpio virtual gpio chip ➱ Each UOS has only one GPIO chip instance, its number of GPIOs is based on acrn-dm command line and GPIO base always start from 0. ➱ Each acrn-dm may be able to access one or more native GPIO chips and all GPIOs are exclusive.
  • 11. virtio-gpio how to access GPIO in UOS int xx_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) { struct gpio_desc *desc; int ret, val; 
 desc = gpiod_get_index(dev->dev, "reset-gpios", 0,GPIOD_IN); or desc = gpiod_get_index(dev->dev, NULL, 0, GPIOD_IN); if (!desc || gpiod_direction_input(desc)) goto err; val = gpiod_get_value(desc); ... }
  • 12. virtio-gpio gpio mapping GPIO Description table Native GPIO name Native GPIO chip Native GPIO offset Virtual GPIO offset reset 0 10 2 shutdown 0 100 0
  • 13. virtio-gpio how to access GPIO from userspace sysfs: For example : cd /sys/class/gpio echo 9 > export echo 0 > gpio9/value cat gpio9/value echo 9 > unexport char device For example : void write_value(unsigned offset, int value) { struct gpiohandle_request req; int ret, fd; 
 fd = open(“/dev/gpiochip0”, O_RDWR); memset(&req, 0, sizeof(req)); req.lineoffsets[0] = offset; req.default_values[0] = value; req.flags = GPIOHANDLE_REQUEST_OUTPUT; req.lines = 1; ret = ioctl(line->chip->fd, GPIO_GET_LINEHANDLE_IOCTL, &req); 
 }
  • 14. GPIO IRQ Virtualization /dev/gpiochipN Virtio-GPIO DM Virtio-GPIO FE driver UOS IRQ consumer Request IRQ Request IRQ Apply the IRQ IRQ event notification Send IRQ information Invoke consumer’s IRQ handler Free IRQ Release IRQ Free the IRQ line event Send IRQ information Return fd Start to poll IRQ event IRQ event notification IRQ event notification Invoke consumer’s IRQ handler 
 Allocate buff Allocate buff 
 

  • 15. Usage ⚫ <gpio resources> <@controller_name{offset|name[=mapping_name]:offset|name[=mapping_name]:
}@controller_name{
}
]> E.g. 1. Map native gpio numbers are 1 and 6, plus one gpio its name is “reset” to frontend, all of them are defined in GPIO controller 0 <@gpiochip0{1:6:reset}> 2. Map native gpio numbers are 1 and 6, which are in gpio controller 0, and native gpio numbers are 2 and 7, which are in gpio controller 1. <@gpiochip0{1:6}@gpiochip1{2:7}> ⚫ [ | acpi resources] [|@device_name{gpio_identifier[=apci name]:gpio_identifier[=apci name]
@device_name{
}
}] E.g. 1. Usb FE driver wants to access “reset” gpio, and it is GPIO controller 0’s “reset” GPIO in native. <@gpiochip0{reset}|@usb{gpiochip0_reset} 2. Usb FE driver wants to access “reset” gpio, and its offset is 2 in the native GPIO controller 0. <@gpiochip0{2}|@usb{gpiochip0_2=reset} ‱
  • 16. Q & A