Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Purpose and usage of GPIO-Hog declaration

Questions

  1. What is the purpose and use-case of the gpio-hog declaration?
  2. Can a 'hogged' gpio pin be interfaced with from Userspace?
  3. If a 'hogged' gpio pin cannot be interfaced with from Userspace, then is there any mechanism to configure GPIO pins in the dts file for Userspace interaction?

Background

I am trying to configure many (10+) GPIOs to speak with a low level chip from Userspace. I have spoken to the chip easily using sysfs exports, but both the documentation in the kernel and programming forums have me concerned about using this mechanisms in our production system.

Reading more kernel documentation I read about gpio-hog declarations and it seemed like the ideal mechanism to at least initially configure the GPIOs. From the documentation:

GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function.

As well as setting the correct low level, vendor settings, I enabled hogging on the desired gpio pins and they came up reporting the correct settings. The problem is that the gpio's are seemingly owned by the kernel and cannot be interfaced with by any Userspace tools such as sysfs or libgpiod. This makes hogging essentially useless to me and also makes me wonder what it's real purpose is. I am exploring libgpiod as a last resort, but the documentation makes it seem that hogging should be the mechanism I use.

like image 271
Liam Kelly Avatar asked Jan 18 '18 15:01

Liam Kelly


People also ask

What is GPIO hog?

GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function. Each GPIO hog definition is represented as a child node of the GPIO controller.

How do I add Gpio to device tree?

Configure pin as GPIO The one for the hardware considered in this guide is microgea-mx6ull-microdev. dts . In order to add a GPIO on the NXP device tree, the relative PAD should be added to the GPIO hog pin control in the iomux node.


1 Answers

hog meaning - to take or use a lot of something in a way that prevents other people from having it

so basically gpio-hog property tells the controller to set the pin high/low during bootup, and no other driver/user space would request it.

If you intend to use the gpio in user space you shouldnt be using gpio-hog

like image 59
Prabhakar Lad Avatar answered Oct 13 '22 10:10

Prabhakar Lad