Go to file
Oliver Smith 3060a2aad5 debian/changelog: add 0.20171115-0osmocom1 2023-06-22 14:07:05 +02:00
debian debian/changelog: add 0.20171115-0osmocom1 2023-06-22 14:07:05 +02:00
.gitignore gitignore: add debian/files 2023-06-22 13:59:24 +02:00
Makefile Fix build failure for kernel >= 5.4 2021-03-19 12:35:34 +01:00
README.md README.md: fix url link to sortbootorder readme file 2021-05-26 21:28:31 +02:00
gpio-nct5104d.c New GPIO interface requires unique bank label. 2019-03-25 23:53:37 +01:00



NCT5104D GPIO Linux Driver

Preconditions (Compile)

you should have the following packages installed:

  • linux-headers-$(uname -r)
  • build-essential
  • make
  • git (you can also download the repo as zip)

apt-get install -y linux-headers-$(uname -r) build-essential make git

git clone <this repo url>


run make in the driver folder on the target machine (otherwise your driver gets compiled for a different kernel version)

You can also provide the custom kernel directory (to compile for different kernel than installed on host. E.g.:

make KDIR=../linux-4.9.0

Kernel has to be prepared first to build the external modules: make modules_prepare

Debian dkms package

Build the package

Install dkms, debhelper and git package on the build machine:

apt-get install -y dkms debhelper

Clone this repository:

git clone <this repo url>

Run dpkg-buildpackage in the driver directory.

Install the deb package

Install dkms on the target machine:

apt-get install -y dkms

Copy the built deb file (e.g. gpio-nct5104d-dkms_0.20171115-0_all.deb) to the target machine and install it:

dpkg -i gpio-nct5104d-dkms_0.20171115-0_all.deb

Now at every kernel package update gpio-nct5104d module will be automatically rebuilt and installed.


Enable GPIOs:

Enabling GPIOs is done in sortbootorder by toggling corresponding UARTs. Please refer to:

Load the driver:

insmod gpio-nct5104d.ko

Unload the driver:

unexport all the used GPIO Pins first, then run rmmod gpio-nct5104d.ko

Export a GPIO Pin:

echo 0 > /sys/class/gpio/export will export/reserve/setup the gpio pin 0

Unexport a GPIO Pin:

echo 0 > /sys/class/gpio/unexport will unexport/free the gpio pin 0

Set GPIO Pin as output:

echo out > /sys/class/gpio/gpio0/direction

Set GPIO Pin output value:

echo 1 > /sys/class/gpio/gpio0/value

Read GPIO Pin value:

cat /sys/class/gpio/gpio0/value

Invert GPIO Pin logic:

echo 1 > /sys/class/gpio/gpio0/active_low


NCT5104D does not provide interrupts for GPIOs.

Show GPIO states using kernel debug information:

cat /sys/kernel/debug/gpio this has to be enabled in your kernel

Additional information

see those pages for some c-code examples:

see the Kernel documentation for more details:

and so on...